From a420cffdfbe0457bb07b9aff2778745929295f88 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 18 Jun 2017 08:02:03 -1000 Subject: Improve pagination of sort=claimed stream forwards --- lib/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/app.js b/lib/app.js index 03760ff..052c767 100644 --- a/lib/app.js +++ b/lib/app.js @@ -274,10 +274,22 @@ App.prototype.pullGetMsg = function (id) { App.prototype.createLogStream = function (opts) { opts = opts || {} return opts.sortByTimestamp - ? this.sbot.createFeedStream(opts) + ? this.createFeedStream(opts) : this.sbot.createLogStream(opts) } +App.prototype.createFeedStream = function (opts) { + // work around opts.gt being treated as opts.gte sometimes + if (opts.gt && opts.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 + }), + opts.limit && pull.take(opts.limit) + ) + return this.sbot.createFeedStream(opts) +} + var stateVals = { connected: 3, connecting: 2, -- cgit v1.2.3