From d437d4de396b37033f03626660b510d7b32e7377 Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 6 May 2017 18:20:57 -1000 Subject: Implement thread forking option --- lib/serve.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'lib/serve.js') diff --git a/lib/serve.js b/lib/serve.js index d9cbfe7..183c8c3 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -741,7 +741,9 @@ Serve.prototype.id = function (id, ext) { self.wrapThread({ recps: recps, root: threadRootId, - branches: id === threadRootId ? threadHeads(links, id) : id, + post: id, + branches: threadHeads(links, threadRootId), + postBranches: threadRootId !== id && threadHeads(links, id), channel: channel, }), self.wrapPage(id), @@ -1179,8 +1181,10 @@ Serve.prototype.wrapThread = function (opts) { placeholder: recps ? 'private reply' : 'reply', id: 'reply', root: opts.root, + post: opts.post, channel: opts.channel || '', branches: opts.branches, + postBranches: opts.postBranches, recps: recps, }, function (err, composer) { if (err) return cb(err) @@ -1360,6 +1364,12 @@ Serve.prototype.composer = function (opts, cb) { channel != null ? h('div', '#', h('input', {name: 'channel', placeholder: 'channel', value: channel})) : '', + opts.root !== opts.post ? h('div', + h('label', {for: 'fork_thread'}, + h('input', {id: 'fork_thread', type: 'checkbox', name: 'fork_thread', value: 'post', checked: data.fork_thread || undefined}), + ' fork thread' + ) + ) : '', h('textarea', { id: opts.id, name: 'text', @@ -1433,8 +1443,13 @@ Serve.prototype.composer = function (opts, cb) { } else { if (opts.recps) content.recps = opts.recps } - if (opts.root) content.root = opts.root - if (opts.branches) content.branch = u.fromArray(opts.branches) + if (data.fork_thread) { + content.root = opts.post || undefined + content.branch = u.fromArray(opts.postBranches) || undefined + } else { + content.root = opts.root || undefined + content.branch = u.fromArray(opts.branches) || undefined + } if (channel) content.channel = data.channel } var msg = { -- cgit v1.2.3