Commit 8778967887283b1aa5eb60fde4c5aad8431fd2e9
edit timestamps should show up at top
Ev Bogue committed on 5/24/2018, 6:38:50 PMParent: c4a5bbce3ba975d7c10582da85771ea6fe6d9f0e
Files changed
compose.js | changed |
render.js | changed |
compose.js | ||
---|---|---|
@@ -1,8 +1,8 @@ | ||
1 | 1 | var h = require('hyperscript') |
2 | 2 | var pull = require('pull-stream') |
3 | 3 | var sbot = require('./scuttlebot') |
4 | - | |
4 | +var human = require('human-time') | |
5 | 5 | var id = require('./keys').id |
6 | 6 | |
7 | 7 | var tools = require('./tools') |
8 | 8 | |
@@ -59,19 +59,24 @@ | ||
59 | 59 | } |
60 | 60 | } |
61 | 61 | |
62 | 62 | if (opts.root) |
63 | - msg.valeu.content.root = opts.root | |
63 | + msg.value.content.root = opts.root | |
64 | 64 | if (opts.original) |
65 | 65 | msg.value.content.original = opts.original |
66 | 66 | if (opts.updated) |
67 | 67 | msg.value.content.updated = opts.updated |
68 | 68 | |
69 | 69 | msg.value.content.text = textarea.value |
70 | 70 | console.log(msg) |
71 | 71 | |
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, | |
74 | 79 | h('div.message__content', tools.markdown(msg.value.content.text)), |
75 | 80 | h('button.btn', 'Publish', { |
76 | 81 | onclick: function () { |
77 | 82 | sbot.publish(msg.value.content, function (err, msg) { |
render.js | ||
---|---|---|
@@ -43,13 +43,16 @@ | ||
43 | 43 | |
44 | 44 | pull( |
45 | 45 | sbot.query({query: [{$filter: {value: {content: {type: 'update', updated: msg.key}}}}]}), |
46 | 46 | 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)) | |
47 | 49 | 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 | |
50 | 52 | ) |
51 | - message.replaceChild(latest, message.childNodes.length) | |
53 | + var r = message.childNodes.length - 2 | |
54 | + message.replaceChild(latest, message.childNodes[r]) | |
52 | 55 | edit.messageText = update.value.content.text |
53 | 56 | edit.original = msg.value.content.original |
54 | 57 | }) |
55 | 58 | ) |
Built with git-ssb-web