From 912a387ae7c8732d21026c16c80eb220526dd6fd Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 9 May 2020 11:09:09 -0400 Subject: Render feedless posts compactly --- lib/render-msg.js | 11 +++++++++++ lib/serve.js | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/render-msg.js b/lib/render-msg.js index d01523e..a1b62e4 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -425,6 +425,17 @@ RenderMsg.prototype.markdownSource = function (text, mentions) { RenderMsg.prototype.post = function (cb) { var self = this + var isFeedless = self.c.root && self.c.root[0] === '@' && !self.c.branch + && typeof self.c.text === 'string' && self.c.text.length <= 139 + if (isFeedless) { + return self.link(self.c.root, function (err, rootLink) { + if (err) return self.wrap(u.renderError(err), cb) + self.wrapMini(h('span', [ + rootLink, ' ', + h('span', {innerHTML: u.unwrapP(self.markdown())}) + ]), cb) + }) + } var done = multicb({pluck: 1, spread: true}) if (self.c.root === self.c.branch) done()() else self.link(self.c.root, done()) diff --git a/lib/serve.js b/lib/serve.js index 7d686a4..71426c3 100644 --- a/lib/serve.js +++ b/lib/serve.js @@ -4622,7 +4622,7 @@ Serve.prototype.composer = function (opts, cb) { function closeIssueCheckbox(cb) { var container = h('div') - if (opts.root) self.getMsgDecryptedMaybeOoo(opts.root, function (err, rootMsg) { + if (opts.root && opts.root[0] === '%') self.getMsgDecryptedMaybeOoo(opts.root, function (err, rootMsg) { if (err) return console.trace(err), cb(null) var rootC = rootMsg && rootMsg.value.content && rootMsg.value.content if (!rootC) return cb(null) @@ -4642,7 +4642,7 @@ Serve.prototype.composer = function (opts, cb) { function mentionAttendeesCheckbox(cb) { var container = h('div') - if (opts.root) self.getMsgDecryptedMaybeOoo(opts.root, function (err, rootMsg) { + if (opts.root && opts.root[0] === '%') self.getMsgDecryptedMaybeOoo(opts.root, function (err, rootMsg) { if (err) return console.trace(err), cb(null) var rootC = rootMsg && rootMsg.value.content && rootMsg.value.content if (!rootC) return cb(null) -- cgit v1.2.3