From 1440f7c6fce5e03dd6c65f4a2e2f81c7d400ca5f Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 18 Jun 2017 07:45:05 -1000 Subject: Handle ?sort=claimed in pagination links --- lib/serve.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/serve.js b/lib/serve.js index 32ea3e0..87ecbb4 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -1154,7 +1154,9 @@ Serve.prototype.renderThreadPaginated = function (opts, feedId, q) { return pull( paginate( function onFirst(msg, cb) { - var num = feedId ? msg.value.sequence : msg.timestamp || msg.ts + var num = feedId ? msg.value.sequence : + opts.sortByTimestamp ? msg.value.timestamp : + msg.timestamp || msg.ts if (q.forwards) { cb(null, links({ lt: num, @@ -1171,7 +1173,9 @@ Serve.prototype.renderThreadPaginated = function (opts, feedId, q) { }, this.app.render.renderFeeds(), function onLast(msg, cb) { - var num = feedId ? msg.value.sequence : msg.timestamp || msg.ts + var num = feedId ? msg.value.sequence : + opts.sortByTimestamp ? msg.value.timestamp : + msg.timestamp || msg.ts if (q.forwards) { cb(null, links({ lt: null, -- cgit v1.2.3