aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-22 18:57:57 -0700
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2019-08-22 19:10:39 -0700
commitf76defc54c292f33838caf35eca329793ff7d733 (patch)
tree214b9ab44f86c0b3971c5119a048711657519867
parent24765da30eaa84bc6084932ad4b80e8fa73b7521 (diff)
downloadpatchfoo-f76defc54c292f33838caf35eca329793ff7d733.tar.gz
patchfoo-f76defc54c292f33838caf35eca329793ff7d733.zip
Implement limit for /new
Fix %CtcZaNNWEWFwdCOZL343mxFXUvqV5BPVMv+CM8ELOCo=.sha256
-rw-r--r--README.md1
-rw-r--r--lib/serve.js9
2 files changed, 10 insertions, 0 deletions
diff --git a/README.md b/README.md
index de42f02..9f108ac 100644
--- a/README.md
+++ b/README.md
@@ -133,6 +133,7 @@ To make config options persistent, set them in `~/.ssb/config`, e.g.:
- `dir`: name of directory in `~/.ssb/` to use for patchfoo things. default: `"patchfoo"`.
- `scriptDir: name of directory in patchfoo's directory (as set by `patchfoo.dir` config option above) to use for user scripts. default: `"script"`.
- `draftsDir: name of directory in patchfoo's directory (as set by `patchfoo.dir` config option above) to use for message draft data. default: `"drafts"`.
+- `newLimit: limit of messages to show on `/new` page. Default: 500. Overridable with query string parameter `limit=...`.
## TODO
diff --git a/lib/serve.js b/lib/serve.js
index 34861bc..1206b36 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -75,6 +75,8 @@ Serve.prototype.go = function () {
this.res.setTimeout(0)
var conf = self.app.config.patchfoo || {}
+ this.conf = conf
+
var authtok = conf.auth || null
if (authtok) {
var auth = this.req.headers['authorization']
@@ -524,8 +526,10 @@ Serve.prototype.new = function (ext) {
var self = this
var q = self.query
var latest = (/latest=([^;]*)/.exec(self.req.headers.cookie) || [])[1]
+ var limit = Number(q.limit || self.conf.newLimit || 500)
var opts = {
gt: Number(q.gt) || Number(latest) || Date.now(),
+ limit: limit
}
if (q.catchup) self.setCookie('latest', opts.gt, {'Max-Age': 86400000})
@@ -552,6 +556,7 @@ Serve.prototype.new = function (ext) {
pull.values(msgs),
self.renderThread(),
self.wrapNew({
+ reachedLimit: msgs.length === limit && limit,
gt: isFinite(maxTS) ? maxTS : Date.now()
}),
self.wrapMessages(),
@@ -3415,10 +3420,14 @@ Serve.prototype.wrapNew = function (opts) {
cb(null, [
composer,
h('table.ssb-msgs',
+ opts.reachedLimit ? h('tr', h('td.paginate.msg-left', {colspan: 3},
+ 'Reached limit of ' + opts.reachedLimit + ' messages'
+ )) : '',
thread,
h('tr', h('td.paginate.msg-left', {colspan: 3},
h('form', {method: 'get', action: ''},
h('input', {type: 'hidden', name: 'gt', value: opts.gt}),
+ self.query.limit ? h('input', {type: 'hidden', name: 'limit', value: self.query.limit}) : '',
h('input', {type: 'hidden', name: 'catchup', value: '1'}),
h('input', {type: 'submit', value: 'catchup'})
)