From 626f5b402618c82bf36ba36321b00956dfb5b2ba Mon Sep 17 00:00:00 2001 From: cel Date: Sat, 9 May 2020 12:13:39 -0400 Subject: Render post reply feed ids alongside branch links --- lib/render-msg.js | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/render-msg.js b/lib/render-msg.js index a1b62e4..c1dd38b 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -439,14 +439,31 @@ RenderMsg.prototype.post = function (cb) { var done = multicb({pluck: 1, spread: true}) if (self.c.root === self.c.branch) done()() else self.link(self.c.root, done()) - self.links(self.c.branch, done()) + var branches = u.toArray(self.c.branch) + self.links(branches, done()) self.links(self.c.fork, done()) - done(function (err, rootLink, branchLinks, forkLinks) { + var replyIById = {} + if (self.c.reply) { + var replyFeeds = [] + for (var k in self.c.reply) { + replyIById[k] = replyFeeds.push(self.c.reply[k])-1 + } + self.links(replyFeeds, done()) + } else done()() + done(function (err, rootLink, branchLinks, forkLinks, replyLinks) { if (err) return self.wrap(u.renderError(err), cb) self.wrap(h('div.ssb-post', rootLink ? h('div', h('small', h('span.symbol', '→'), ' ', rootLink)) : '', branchLinks.map(function (a, i) { - return h('div', h('small', h('span.symbol', '  ↳'), ' ', a)) + var replyLink + if (self.c.reply) { + var branchId = branches[i] + var replyI = replyIById[branchId] + replyLink = replyLinks[replyI] + } + return h('div', h('small', h('span.symbol', '  ↳'), ' ', + replyLink ? [replyLink, ' '] : '', + a)) }), forkLinks.map(function (a, i) { return h('div', h('small', h('span.symbol', '⑂'), ' ', a)) -- cgit v1.2.3