aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-10-17 12:31:56 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-10-17 12:36:41 -1000
commit6d54ac255cb2f96433e88d9c2482074749bd4eea (patch)
tree29a71a77eb1aeee2e9a735f274fc1c89b1c6e5ba
parent5299f99daca8d6d71597eb1f8b6d4115d76bfa2a (diff)
downloadpatchfoo-6d54ac255cb2f96433e88d9c2482074749bd4eea.tar.gz
patchfoo-6d54ac255cb2f96433e88d9c2482074749bd4eea.zip
Fix handling limit
-rw-r--r--lib/app.js2
-rw-r--r--lib/render.js11
-rw-r--r--lib/serve.js16
3 files changed, 18 insertions, 11 deletions
diff --git a/lib/app.js b/lib/app.js
index b5140e1..3374f41 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -355,7 +355,7 @@ App.prototype.createLogStream = function (opts) {
App.prototype.createFeedStream = function (opts) {
// work around opts.gt being treated as opts.gte sometimes
var limit = Number(opts.limit)
- if (opts.gt && opts.limit && !opts.reverse) return pull(
+ if (opts.gt && limit && !opts.reverse) return pull(
this.sbot.createFeedStream(u.mergeOpts(opts, {limit: opts.limit + 1})),
pull.filter(function (msg) {
return msg && msg.value.timestamp !== opts.gt
diff --git a/lib/render.js b/lib/render.js
index a86bd92..c43ee76 100644
--- a/lib/render.js
+++ b/lib/render.js
@@ -314,9 +314,14 @@ Render.prototype.renderMsg = function (msg, opts, cb) {
Render.prototype.renderFeeds = function (opts) {
var self = this
- return paramap(function (msg, cb) {
- self.renderMsg(msg, opts, cb)
- }, 4)
+ var limit = Number(opts.limit)
+ return pull(
+ paramap(function (msg, cb) {
+ self.renderMsg(msg, opts, cb)
+ }, 4),
+ pull.filter(Boolean),
+ limit && pull.take(limit)
+ )
}
Render.prototype.gitCommitBody = function (body) {
diff --git a/lib/serve.js b/lib/serve.js
index 56fddef..2bbc80d 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -351,7 +351,6 @@ Serve.prototype.public = function (ext) {
this.app.createLogStream(opts),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
- pull.take(Number(q.limit) || 12),
this.wrapPublic(),
this.wrapPage('public'),
this.respondSink(200, {
@@ -422,7 +421,6 @@ Serve.prototype.private = function (ext) {
pull(
this.app.streamPrivate(opts),
- pull.take(Number(q.limit) || 12),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapPrivate(opts),
@@ -449,7 +447,6 @@ Serve.prototype.mentions = function (ext) {
ph('h3', 'Mentions'),
pull(
self.app.streamMentions(opts),
- pull.take(Number(q.limit) || 12),
self.app.unboxMessages(),
self.renderThreadPaginated(opts, null, q),
self.wrapMessages()
@@ -917,7 +914,6 @@ Serve.prototype.type = function (path) {
pull(
this.app.sbot.messagesByType(opts),
- pull.take(Number(q.limit) || 12),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapType(type),
@@ -983,7 +979,6 @@ Serve.prototype.channel = function (path) {
pull(
this.app.streamChannel(opts),
- pull.take(Number(q.limit) || 12),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapChannel(channel),
@@ -1065,7 +1060,6 @@ Serve.prototype.userFeed = function (id, path) {
if (err) self.app.error(err)
pull(
self.app.sbot.createUserStream(opts),
- pull.take(Number(q.limit) || 20),
self.renderThreadPaginated(opts, id, q),
self.wrapMessages(),
self.wrapUserFeed(isScrolled, id),
@@ -1242,6 +1236,7 @@ Serve.prototype.renderThread = function (opts) {
feed: opts && opts.feed,
msgId: opts && opts.msgId,
filter: this.query.filter,
+ limit: Number(this.query.limit) || 12,
}),
pull.map(u.toHTML)
)
@@ -1285,7 +1280,14 @@ Serve.prototype.renderThreadPaginated = function (opts, feedId, q) {
}))
}
},
- this.app.render.renderFeeds(opts),
+ this.app.render.renderFeeds({
+ raw: false,
+ full: this.query.full != null,
+ feed: opts && opts.feed,
+ msgId: opts && opts.msgId,
+ filter: this.query.filter,
+ limit: Number(this.query.limit) || 12,
+ }),
function onLast(msg, cb) {
var num = feedId ? msg.value.sequence :
opts.sortByTimestamp ? msg.value.timestamp :