git ssb

2+

ev / mvd



Commit cbf24e8da77b1e2bcb8194c2eb7e47ce78f37379

quick fix because private message edits broke render

Ev Bogue committed on 1/3/2019, 5:30:41 PM
Parent: 35599c2543afac880b2c55fbf32989a543c1747f

Files changed

render.jschanged
render.jsView
@@ -18,9 +18,9 @@
1818 }
1919
2020 module.exports = function (msg) {
2121 var message = h('div.message#' + msg.key.substring(0, 44))
22-
22 +
2323 if (!localStorage[msg.value.author])
2424 var cache = {mute: false}
2525 else
2626 var cache = JSON.parse(localStorage[msg.value.author])
@@ -42,39 +42,43 @@
4242
4343 }
4444 return message
4545 }
46-
46 +
4747 else if (msg.value.content.type == 'edit') {
4848 message.appendChild(tools.header(msg))
49- var current = msg.value.content.text
50- sbot.get(msg.value.content.updated, function (err, updated) {
51- if (updated) {
52- fragment = document.createDocumentFragment()
53- var previous = updated.content.text
54- var ready = diff.diffWords(previous, current)
55- ready.forEach(function (part) {
56- if (part.added === true) {
57- color = 'cyan'
58- } else if (part.removed === true) {
59- color = 'gray'
60- } else {color = 'white'}
61- var span = h('span')
62- span.style.color = color
63- if (part.removed === true) {
64- span.appendChild(h('del', document.createTextNode(part.value)))
65- } else {
66- span.appendChild(document.createTextNode(part.value))
49 + if (msg.value.content.text) {
50 + var current = msg.value.content.text
51 + sbot.get(msg.value.content.updated, function (err, updated) {
52 + if (updated) {
53 + // quick fix, need to decrypt messages if they're private
54 + if (updated.content.text) {
55 + fragment = document.createDocumentFragment()
56 + var previous = updated.content.text
57 + var ready = diff.diffWords(previous, current)
58 + ready.forEach(function (part) {
59 + if (part.added === true) {
60 + color = 'blue'
61 + } else if (part.removed === true) {
62 + color = 'gray'
63 + } else {color = '#333'}
64 + var span = h('span')
65 + span.style.color = color
66 + if (part.removed === true) {
67 + span.appendChild(h('del', document.createTextNode(part.value)))
68 + } else {
69 + span.appendChild(document.createTextNode(part.value))
70 + }
71 + fragment.appendChild(span)
72 + })
73 + message.appendChild(h('code', fragment))
6774 }
68- fragment.appendChild(span)
69- })
70- message.appendChild(h('code', fragment))
71- }
72- })
75 + }
76 + })
77 + }
7378 return message
7479 }
7580
76-
7781 else if (msg.value.content.type == 'scat_message') {
7882 var src = hash()
7983 if (src != 'backchannel') {
8084 message.appendChild(h('button.btn.right', h('a', {href: '#backchannel'}, 'Chat')))
@@ -338,12 +342,12 @@
338342 } else {
339343
340344 //FULL FALLBACK
341345 message.appendChild(tools.header(msg))
342- message.appendChild(h('pre', tools.rawJSON(msg.value.content)))
346 + message.appendChild(h('pre', tools.rawJSON(msg.value)))
343347
344348 //MINI FALLBACK
345349 //var fallback = h('span', ' ' + msg.value.content.type)
346350 //message.appendChild(tools.mini(msg, fallback))
347- return h('div')//message
351 + return h('div', message)
348352 }
349353 }

Built with git-ssb-web