aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-06-18 08:02:03 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-06-18 08:02:03 -1000
commita420cffdfbe0457bb07b9aff2778745929295f88 (patch)
tree9e0b383b59f2cbd0c2af9739673b7cd942391937
parent1440f7c6fce5e03dd6c65f4a2e2f81c7d400ca5f (diff)
downloadpatchfoo-a420cffdfbe0457bb07b9aff2778745929295f88.tar.gz
patchfoo-a420cffdfbe0457bb07b9aff2778745929295f88.zip
Improve pagination of sort=claimed stream forwards
-rw-r--r--lib/app.js14
1 files changed, 13 insertions, 1 deletions
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,