diff options
author | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-06-18 13:49:42 -0400 |
---|---|---|
committer | cel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519> | 2018-06-18 13:49:42 -0400 |
commit | d51ccc5142d4429b324bedb37b96fd5e2bcee4f0 (patch) | |
tree | 996342ac1325d9624f0a58106a2352b444cd5d8d /lib/render-msg.js | |
parent | 462de772ed178e879d70a437689893ff60d1f99e (diff) | |
download | patchfoo-d51ccc5142d4429b324bedb37b96fd5e2bcee4f0.tar.gz patchfoo-d51ccc5142d4429b324bedb37b96fd5e2bcee4f0.zip |
Render tag messages
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r-- | lib/render-msg.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js index cda8eab..afbdc00 100644 --- a/lib/render-msg.js +++ b/lib/render-msg.js @@ -299,6 +299,7 @@ RenderMsg.prototype.message = function (cb) { case 'position': if (this.c.version === 'v1') return this.pollPosition(cb) case 'scat_message': return this.scat(cb) case 'share': return this.share(cb) + case 'tag': return this.tag(cb) default: return this.object(cb) } } @@ -426,6 +427,8 @@ RenderMsg.prototype.title1 = function (cb) { cb(null, self.c.name) else if (self.c.type === 'talenet-idea-create') self.app.getIdeaTitle(self.msg.key, cb) + else if (self.c.type === 'tag') + self.tagTitle(cb) else self.app.getAbout(self.msg.key, function (err, about) { if (err) return cb(err) @@ -1827,3 +1830,48 @@ RenderMsg.prototype.share = function (cb) { ], cb) }) } + +RenderMsg.prototype.tag = function (cb) { + var done = multicb({pluck: 1, spread: true}) + var self = this + if (self.c.message || self.c.root) { + self.link(self.c.root, done()) + self.link(self.c.message, done()) + self.links(self.c.branch, done()) + done(function (err, rootLink, msgLink, branchLinks) { + if (err) return self.wrap(u.renderError(err), cb) + return self.wrap(h('div', + branchLinks.map(function (a, i) { + return h('div', h('small', h('span.symbol', ' ↳'), ' ', a)) + }), + h('p', + self.c.tagged ? 'tagged ' : 'untagged ', + msgLink, + rootLink ? [' as ', rootLink] : '' + ), + ), cb) + }) + } else { + self.wrapMini('tag', cb) + } +} + +RenderMsg.prototype.tagTitle = function (cb) { + var self = this + if (!self.c.message && !self.c.root) { + return self.app.getAbout(self.msg.key, function (err, about) { + if (err) return cb(err) + var name = about.name || about.title + || (about.description && mdInline(about.description)) + cb(null, truncate(name ? name.replace(/^%/, '') : self.msg.key, 72)) + }) + } + var done = multicb({pluck: 1, spread: true}) + self.getName(self.c.root, done()) + self.getName(self.c.message, done()) + done(function (err, rootName, msgName) { + if (err) return cb(null, err.stack) + cb(null, (self.c.tagged ? 'tagged ' : 'untagged ') + + msgName + ' as ' + rootName) + }) +} |