aboutsummaryrefslogtreecommitdiff
path: root/lib/render-msg.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/render-msg.js')
-rw-r--r--lib/render-msg.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index 23e236f..703f5cd 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -10,10 +10,12 @@ function RenderMsg(render, app, msg, opts) {
this.render = render
this.app = app
this.msg = msg
+ this.value = msg && msg.value || {}
+ var content = this.value.content
+ this.c = content || {}
+ this.isMissing = !content
var opts = opts || {}
this.shouldWrap = opts.wrap !== false
-
- this.c = msg.value.content || {}
}
RenderMsg.prototype.toUrl = function (href) {
@@ -125,13 +127,13 @@ RenderMsg.prototype.wrap = function (content, cb) {
RenderMsg.prototype.wrapMini = function (content, cb) {
if (!this.shouldWrap) return cb(null, content)
- var date = new Date(this.msg.value.timestamp)
+ var date = new Date(this.value.timestamp)
var self = this
var channel = this.c.channel ? '#' + this.c.channel : ''
var done = multicb({pluck: 1, spread: true})
done()(null, h('tr.msg-row',
h('td.msg-left',
- this.render.idLink(this.msg.value.author, done()), ' ',
+ this.render.idLink(this.value.author, done()), ' ',
this.recpsLine(done()),
channel ? [h('a', {href: this.toUrl(channel)}, channel), ' '] : ''),
h('td.msg-main',
@@ -154,8 +156,8 @@ RenderMsg.prototype.wrapMini = function (content, cb) {
}
RenderMsg.prototype.recpsLine = function (cb) {
- if (!this.msg.value.private) return cb(), ''
- var author = this.msg.value.author
+ if (!this.value.private) return cb(), ''
+ var author = this.value.author
var recpsNotSelf = u.toArray(this.c.recps).filter(function (link) {
return u.linkDest(link) !== author
})
@@ -163,7 +165,7 @@ RenderMsg.prototype.recpsLine = function (cb) {
}
RenderMsg.prototype.recpsIds = function () {
- return this.msg.value.private
+ return this.value.private
? u.toArray(this.c.recps).map(u.linkDest)
: []
}
@@ -181,6 +183,7 @@ RenderMsg.prototype.voteFormInner = function (expression) {
RenderMsg.prototype.message = function (raw, cb) {
if (raw) return this.raw(cb)
if (typeof this.c === 'string') return this.encrypted(cb)
+ if (this.isMissing) return this.missing(cb)
switch (this.c.type) {
case 'post': return this.post(cb)
case 'ferment/like':
@@ -458,6 +461,10 @@ RenderMsg.prototype.object = function (cb) {
this.wrapMini(h('pre', this.c.type), cb)
}
+RenderMsg.prototype.missing = function (cb) {
+ this.wrapMini(h('code', 'MISSING'), cb)
+}
+
RenderMsg.prototype.issues = function (cb) {
var self = this
var done = multicb({pluck: 1, spread: true})