git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit 8778967887283b1aa5eb60fde4c5aad8431fd2e9

edit timestamps should show up at top

Ev Bogue committed on 5/24/2018, 6:38:50 PM
Parent: c4a5bbce3ba975d7c10582da85771ea6fe6d9f0e

Files changed

compose.jschanged
render.jschanged
compose.jsView
@@ -1,8 +1,8 @@
11 var h = require('hyperscript')
22 var pull = require('pull-stream')
33 var sbot = require('./scuttlebot')
4-
4+var human = require('human-time')
55 var id = require('./keys').id
66
77 var tools = require('./tools')
88
@@ -59,19 +59,24 @@
5959 }
6060 }
6161
6262 if (opts.root)
63- msg.valeu.content.root = opts.root
63+ msg.value.content.root = opts.root
6464 if (opts.original)
6565 msg.value.content.original = opts.original
6666 if (opts.updated)
6767 msg.value.content.updated = opts.updated
6868
6969 msg.value.content.text = textarea.value
7070 console.log(msg)
7171
72- var preview = h('div',
73- tools.header(msg),
72+ if (opts.type == 'post')
73+ var header = tools.header(msg)
74+ if (opts.type == 'update')
75+ var header = h('div.timestamp', 'Edited:', h('a', {href: msg.key}, human(new Date(msg.value.timestamp))))
76+
77+ var preview = h('div',
78+ header,
7479 h('div.message__content', tools.markdown(msg.value.content.text)),
7580 h('button.btn', 'Publish', {
7681 onclick: function () {
7782 sbot.publish(msg.value.content, function (err, msg) {
render.jsView
@@ -43,13 +43,16 @@
4343
4444 pull(
4545 sbot.query({query: [{$filter: {value: {content: {type: 'update', updated: msg.key}}}}]}),
4646 pull.drain(function (update) {
47+ var newTimestamp = h('span.timestamp', 'Edited: ', h('a', {href: '#' + update.key}, human(new Date(update.value.timestamp))))
48+ var newMessage = h('div', tools.markdown(update.value.content.text))
4749 var latest = h('div.message__body',
48- tools.markdown(update.value.content.text),
49- h('span.timestamp', 'Edited: ', h('a', {href: '#' + update.key}, human(new Date(update.value.timestamp))))
50+ newTimestamp,
51+ newMessage
5052 )
51- message.replaceChild(latest, message.childNodes.length)
53+ var r = message.childNodes.length - 2
54+ message.replaceChild(latest, message.childNodes[r])
5255 edit.messageText = update.value.content.text
5356 edit.original = msg.value.content.original
5457 })
5558 )

Built with git-ssb-web