aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-08 11:43:41 -0800
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2017-02-08 11:43:41 -0800
commit07d1f78debbe5e7e89a81d0b3c7300e950976ed2 (patch)
tree7a0019f679906daeda66237e1263e6c6b5009c40
parentac3d249d64c586e8e000b45b7ca96773b2de61af (diff)
downloadpatchfoo-07d1f78debbe5e7e89a81d0b3c7300e950976ed2.tar.gz
patchfoo-07d1f78debbe5e7e89a81d0b3c7300e950976ed2.zip
Allow sorting by timestamp
-rw-r--r--lib/app.js7
-rw-r--r--lib/serve.js6
2 files changed, 11 insertions, 2 deletions
diff --git a/lib/app.js b/lib/app.js
index cb9ad6d..faed5fc 100644
--- a/lib/app.js
+++ b/lib/app.js
@@ -111,3 +111,10 @@ function getAbout(sbot, src, id, cb) {
cb(null, about)
})
}
+
+App.prototype.createLogStream = function (opts) {
+ opts = opts || {}
+ return opts.sortByTimestamp
+ ? this.sbot.createFeedStream(opts)
+ : this.sbot.createLogStream(opts)
+}
diff --git a/lib/serve.js b/lib/serve.js
index f850302..9809696 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -145,13 +145,14 @@ Serve.prototype.public = function (ext) {
var q = this.query
var opts = {
reverse: !q.forwards,
+ sortByTimestamp: q.sort === 'claimed',
lt: Number(q.lt) || Date.now(),
gt: Number(q.gt) || -Infinity,
limit: Number(q.limit) || 12
}
pull(
- this.app.sbot.createLogStream(opts),
+ this.app.createLogStream(opts),
this.renderThreadPaginated(opts, null, q),
this.wrapMessages(),
this.wrapPublic(),
@@ -166,13 +167,14 @@ Serve.prototype.private = function (ext) {
var q = this.query
var opts = {
reverse: !q.forwards,
+ sortByTimestamp: q.sort === 'claimed',
lt: Number(q.lt) || Date.now(),
gt: Number(q.gt) || -Infinity,
}
var limit = Number(q.limit) || 12
pull(
- this.app.sbot.createLogStream(opts),
+ this.app.createLogStream(opts),
pull.filter(isMsgEncrypted),
paramap(this.app.unboxMsg, 4),
pull.filter(isMsgReadable),