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.js28
1 files changed, 16 insertions, 12 deletions
diff --git a/lib/render-msg.js b/lib/render-msg.js
index cc85190..d056bc4 100644
--- a/lib/render-msg.js
+++ b/lib/render-msg.js
@@ -24,6 +24,8 @@ function RenderMsg(render, app, msg, opts) {
if (typeof opts === 'boolean') opts = {raw: opts}
this.opts = opts || {}
this.shouldWrap = this.opts.wrap !== false
+ var ts = this.value.timestamp
+ this.date = ts ? new Date(ts) : null
}
RenderMsg.prototype.getMsg = function (id, cb) {
@@ -121,8 +123,6 @@ RenderMsg.prototype.raw = function (cb) {
RenderMsg.prototype.wrap = function (content, cb) {
if (!this.shouldWrap) return cb(null, content)
- var ts = this.msg.value.timestamp
- var date = ts ? new Date(ts) : null
var self = this
var channel = this.c.channel ? '#' + u.toString(this.c.channel) : ''
var done = multicb({pluck: 1, spread: true})
@@ -135,10 +135,10 @@ RenderMsg.prototype.wrap = function (content, cb) {
),
h('td.msg-main',
h('div.msg-header',
- date && !this.serve.noMsgTime ? [h('a.ssb-timestamp', {
- title: date.toLocaleString(),
+ this.date && !this.serve.noMsgTime ? [h('a.ssb-timestamp', {
+ title: this.date.toLocaleString(),
href: this.msg.key ? this.toUrl(this.msg.key) : undefined
- }, htime(date)), ' '] : '',
+ }, htime(this.date)), ' '] : '',
h('code', h('a.ssb-id', {
href: this.toUrl(this.msg.key) +
(this.hasFullLink && this.opts.full ? '?full' : '')
@@ -163,8 +163,6 @@ RenderMsg.prototype.wrap = function (content, cb) {
RenderMsg.prototype.wrapMini = function (content, cb) {
if (!this.shouldWrap) return cb(null, content)
- var ts = this.value.timestamp
- var date = ts ? new Date(ts) : null
var self = this
var channel = this.c.channel ? '#' + this.c.channel : ''
var done = multicb({pluck: 1, spread: true})
@@ -174,10 +172,10 @@ RenderMsg.prototype.wrapMini = function (content, cb) {
this.recpsLine(done()),
channel ? [h('a', {href: this.toUrl(channel)}, channel), ' '] : ''),
h('td.msg-main',
- date ? [h('a.ssb-timestamp', {
- title: date.toLocaleString(),
+ this.date ? [h('a.ssb-timestamp', {
+ title: this.date.toLocaleString(),
href: this.msg.key ? this.toUrl(this.msg.key) : undefined
- }, htime(date)), ' '] : '',
+ }, htime(this.date)), ' '] : '',
this.issues(done()),
this.c.contentWarning ? [
h('details', [
@@ -193,7 +191,12 @@ RenderMsg.prototype.wrapMini = function (content, cb) {
RenderMsg.prototype.actions = function (mini) {
var lastMove
var ooo = this.serve && this.serve.query.ooo
- if (this.serve.noActions) return
+ var extra = [
+ this.serve.msgDate ? [
+ this.date.toISOString().substr(0, 10)
+ ] : ''
+ ]
+ if (this.serve.noActions) return extra
return this.msg.key ?
h('form', {method: 'post', action: ''},
this.msg.rel ? [this.msg.rel, ' '] : '',
@@ -223,7 +226,8 @@ RenderMsg.prototype.actions = function (mini) {
title: 'view raw message'}, 'raw'), ' ',
this.buttonsCommon(),
this.c.type === 'gathering' ? [this.attendButton(), ' '] : '',
- this.voteButton('dig')
+ this.voteButton('dig'),
+ extra
) : [
this.msg.rel ? [this.msg.rel, ' '] : ''
]