aboutsummaryrefslogtreecommitdiff
path: root/lib/render-msg.js
diff options
context:
space:
mode:
authorcel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 19:11:15 -1000
committercel <cel@f/6sQ6d2CMxRUhLpspgGIulDxDCwYD7DzFzPNr7u5AU=.ed25519>2018-01-08 19:11:15 -1000
commitcbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6 (patch)
tree24636f66aece489ca88a0bb05f96ee02a51855fe /lib/render-msg.js
parent498eaa3edf1241abdc6180410db97254c70e2185 (diff)
downloadpatchfoo-cbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6.tar.gz
patchfoo-cbf9a1d87eb43eaea73e6c019e7b4a2dca3bbaa6.zip
Render line-comment messages
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r--lib/render-msg.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index d4ad670..0835fee 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -10,6 +10,7 @@ function RenderMsg(render, app, msg, opts) {
this.render = render
this.app = app
this.msg = msg
+ this.serve = opts.serve
this.value = msg && msg.value || {}
var content = this.value.content
this.c = content || {}
@@ -20,6 +21,13 @@ function RenderMsg(render, app, msg, opts) {
this.shouldWrap = this.opts.wrap !== false
}
+RenderMsg.prototype.getMsg = function (id, cb) {
+ if (!id) return cb()
+ return this.serve
+ ? this.serve.getMsgDecryptedMaybeOoo(id, cb)
+ : this.app.getMsgDecryptedOoo(id, cb)
+}
+
RenderMsg.prototype.toUrl = function (href) {
return this.render.toUrl(href)
}
@@ -287,6 +295,7 @@ RenderMsg.prototype.message = function (cb) {
case 'talenet-idea-comment':
case 'talenet-idea-comment_reply': return this.ideaComment(cb)
case 'about-resource': return this.aboutResource(cb)
+ case 'line-comment': return this.lineComment(cb)
default: return this.object(cb)
}
}
@@ -1638,3 +1647,30 @@ RenderMsg.prototype.aboutResource = function (cb) {
h('blockquote', {innerHTML: self.render.markdown(self.c.description)})
), cb)
}
+
+RenderMsg.prototype.lineComment = function (cb) {
+ var self = this
+ var done = multicb({pluck: 1, spread: true})
+ self.link(self.c.repo, done())
+ self.getMsg(self.c.updateId, done())
+ done(function (err, repoLink, updateMsg) {
+ if (err) return cb(err)
+ return self.wrap(h('div',
+ h('div', h('small', '> ',
+ repoLink, ' ',
+ h('a', {
+ href: self.toUrl(self.c.updateId)
+ },
+ updateMsg
+ ? htime(new Date(updateMsg.value.timestamp))
+ : String(self.c.updateId)
+ ), ' ',
+ h('a', {
+ href: self.toUrl('/git/commit/' + self.c.commitId + '?msg=' + encodeURIComponent(self.c.updateId))
+ }, String(self.c.commitId).substr(0, 8)), ' ',
+ h('code', self.c.filePath + ':' + self.c.line)
+ )),
+ self.c.text ?
+ h('div', {innerHTML: self.render.markdown(self.c.text)}) : ''), cb)
+ })
+}