git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit cf23c56e2b9a801e98a978e077454fa36839c631

make it possible to cancel edit composer

Ev Bogue committed on 5/25/2018, 3:37:39 AM
Parent: 3bf3c7aca4c5ebf780ce5daee70c769f82f5ca26

Files changed

compose.jschanged
render.jschanged
compose.jsView
@@ -105,14 +105,21 @@
105105 textarea.value += embed + '['+file.name+']('+file.link+')'
106106 }),
107107 h('button.btn', 'Cancel', {
108108 onclick: function () {
109- var message = document.getElementById(opts.branch.substring(0,10))
110- if (opts.updated)
111- message.parentNode.removeChild(message)
112- else
113- message.parentNode.removeChild(message)
109+ var cancel
110+ if (opts.updated) {
111+ cancel = document.getElementById(opts.updated.substring(0,10))
112+ var oldMessage = h('div.message__body', tools.markdown(opts.messageText))
113+ cancel.parentNode.replaceChild(oldMessage, cancel)
114+ console.log(opts.buttons)
115+ oldMessage.parentNode.appendChild(opts.buttons)
116+ } else {
117+ cancel = document.getElementById(opts.branch.substring(0,10))
118+ cancel.parentNode.removeChild(cancel)
119+ }
114120 }
121+
115122 })
116123 )
117124
118125 composer.appendChild(container)
render.jsView
@@ -67,11 +67,12 @@
6767 }))
6868 if (msg.value.author == id)
6969 buttons.appendChild(h('button.btn', 'Edit', {
7070 onclick: function () {
71- var compose = composer(edit)
7271 var r = message.childNodes.length - 1
72+ edit.buttons = message.childNodes[r]
7373 message.removeChild(message.childNodes[r])
74+ var compose = h('div#' + edit.updated.substring(0, 10), composer(edit))
7475 message.replaceChild(compose, message.lastElementChild)
7576 }
7677 }))
7778

Built with git-ssb-web