git ssb

0+

ev / 0qc



Commit 8153d042fa6ff17e4b0802cb01b297429c6e5ec4

add edits

Ev Bogue committed on 3/13/2019, 10:27:58 PM
Parent: 4900bfb0b9703e05ea09ad735590650aa536d492

Files changed

render.jschanged
render.jsView
@@ -79,11 +79,35 @@
7979 (msg.value.content.root == data.value.content.root)
8080 ) {
8181 message.appendChild(h('div.submessage', (exports.render(data))))
8282 }
83 +
84 +
85 +
86 +
87 + } else if (data.value.content.type == 'edit') {
88 +
89 +
90 +
91 + message.appendChild(h('div.submessage', (exports.render(data))))
92 +
93 +
94 + var editedMessage = h('div.messageContent')
95 +
96 + editedMessage.appendChild(tools.header(msg))
97 + editedMessage.appendChild(tools.timestamp(data, {edited: true})),
98 + editedMessage.appendChild(h('div.message__body', tools.markdown(data.value.content.text)))
99 +
100 +
101 +
102 + message.replaceChild(editedMessage, message.firstChild)
103 +
104 +
105 +
106 +
107 +
83108 } else if (data.value.content.type == 'git-update') {
84109 message.appendChild(h('div.submessage', (exports.render(data))))
85-
86110 } else {
87111 var link = h('span', ' backlinked from ', tools.messageLink(data.key))
88112 message.appendChild(h('div.submessage', h('div.messageContent', tools.mini(data, link))))
89113 }
@@ -91,9 +115,42 @@
91115 }
92116 }
93117 })
94118 )
95-
119 + if (msg.value.content.type == 'edit') {
120 + messageContent.appendChild(tools.header(msg))
121 + if (msg.value.content.text) {
122 + var current = msg.value.content.text
123 + sbot.get(msg.value.content.updated, function (err, updated) {
124 + if (updated) {
125 + // quick fix, need to decrypt messages if they're private
126 + if (updated.content.text) {
127 + fragment = document.createDocumentFragment()
128 + var previous = updated.content.text
129 + var ready = diff.diffWords(previous, current)
130 + ready.forEach(function (part) {
131 + if (part.added === true) {
132 + color = 'cyan'
133 + } else if (part.removed === true) {
134 + color = 'gray'
135 + } else {color = '#333'}
136 + var span = h('span')
137 + span.style.color = color
138 + if (part.removed === true) {
139 + span.appendChild(h('del', document.createTextNode(part.value)))
140 + } else {
141 + span.appendChild(document.createTextNode(part.value))
142 + }
143 + fragment.appendChild(span)
144 + })
145 + messageContent.appendChild(h('code', fragment))
146 + }
147 + }
148 + })
149 + }
150 + return message
151 +
152 + }
96153 if (msg.value.content.type == 'post') {
97154
98155 var opts = {
99156 type: 'post',

Built with git-ssb-web