git ssb

1+

punkmonk.termux / mvd



forked from ev / mvd

Commit c0fd0e300786fa560756710190772845cd949008

remove preview when publishing replies and root posts

Ev Bogue committed on 5/25/2018, 9:48:11 PM
Parent: e3b6a2cde0471d83afe35e6ab1514feee59047cd

Files changed

compose.jschanged
compose.jsView
@@ -52,18 +52,18 @@
5252 if (window.location.hash.substring(1) != 'compose')
5353 var cancelBtn = h('button.btn', 'Cancel', {
5454 onclick: function () {
5555 var cancel
56- if (opts.updated) {
56+ if (opts.type == 'updated') {
5757 cancel = document.getElementById(opts.updated.substring(0,10))
5858 var oldMessage = h('div.message__body', tools.markdown(opts.messageText))
5959 cancel.parentNode.replaceChild(oldMessage, cancel)
6060 oldMessage.parentNode.appendChild(buttons)
61- } else if (opts.branch) {
62- cancel = document.getElementById(opts.branch.substring(0,10))
63- cancel.parentNode.removeChild(cancel)
6461 } else {
65- cancel = document.getElementById('composer')
62+ if (document.getElementById(opts.branch.substring(0,10)))
63+ cancel = document.getElementById(opts.branch.substring(0,10))
64+ else
65+ cancel = document.getElementById('composer')
6666 cancel.parentNode.removeChild(cancel)
6767 }
6868 }
6969
@@ -74,63 +74,72 @@
7474
7575 var initialButtons = h('span',
7676 h('button.btn', 'Preview', {
7777 onclick: function () {
78-
79- var msg = {}
80- msg.value = {
81- "author": id,
82- "content": {
83- "type": opts.type
78+ if (textarea.value) {
79+ var msg = {}
80+ msg.value = {
81+ "author": id,
82+ "content": {
83+ "type": opts.type
84+ }
8485 }
85- }
8686
87- if (opts.root)
88- msg.value.content.root = opts.root
89- if (opts.original)
90- msg.value.content.original = opts.original
91- if (opts.updated)
92- msg.value.content.updated = opts.updated
87+ if (opts.root)
88+ msg.value.content.root = opts.root
89+ if (opts.original)
90+ msg.value.content.original = opts.original
91+ if (opts.updated)
92+ msg.value.content.updated = opts.updated
9393
94- msg.value.content.text = textarea.value
95- console.log(msg)
94+ msg.value.content.text = textarea.value
95+ console.log(msg)
9696
97- if (opts.type == 'post')
98- var header = tools.header(msg)
99- if (opts.type == 'update')
100- var header = h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp))))
97+ if (opts.type == 'post')
98+ var header = tools.header(msg)
99+ if (opts.type == 'update')
100+ var header = h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp))))
101101
102- var preview = h('div',
103- header,
104- h('div.message__content', tools.markdown(msg.value.content.text)),
105- h('button.btn', 'Publish', {
106- onclick: function () {
107- sbot.publish(msg.value.content, function (err, msg) {
108- if(err) throw err
109- console.log('Published!', msg)
110- if (opts.type == 'update') {
111- var originalMessage = document.getElementById(opts.updated.substring(0,10))
112- console.log(originalMessage)
113- opts.messageText = msg.value.content.text
114- var newMessage = h('div.message__body',
115- h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp)))),
116- h('div', tools.markdown(msg.value.content.text))
117- )
118- originalMessage.parentNode.replaceChild(newMessage, originalMessage)
119- newMessage.parentNode.appendChild(buttons)
102+ var preview = h('div',
103+ header,
104+ h('div.message__content', tools.markdown(msg.value.content.text)),
105+ h('button.btn', 'Publish', {
106+ onclick: function () {
107+ if (msg.value.content) {
108+ sbot.publish(msg.value.content, function (err, msg) {
109+ if(err) throw err
110+ console.log('Published!', msg)
111+ if (opts.type == 'update') {
112+ var originalMessage = document.getElementById(opts.updated.substring(0,10))
113+ console.log(originalMessage)
114+ opts.messageText = msg.value.content.text
115+ var newMessage = h('div.message__body',
116+ h('div.timestamp', 'Edited: ', h('a', {href: msg.key}, human(new Date(msg.value.timestamp)))),
117+ h('div', tools.markdown(msg.value.content.text))
118+ )
119+ originalMessage.parentNode.replaceChild(newMessage, originalMessage)
120+ newMessage.parentNode.appendChild(buttons)
121+ } else {
122+ if (opts.branch)
123+ cancel = document.getElementById(opts.branch.substring(0,10))
124+ else
125+ cancel = document.getElementById('composer')
126+ cancel.parentNode.removeChild(cancel)
127+ }
128+ })
120129 }
121- })
122- }
123- }),
124- h('button.btn', 'Cancel', {
125- onclick: function () {
126- composer.replaceChild(container, composer.firstChild)
127- container.appendChild(textarea)
128- container.appendChild(initialButtons)
129- }
130- })
131- )
132- composer.replaceChild(preview, composer.firstChild)
130+ }
131+ }),
132+ h('button.btn', 'Cancel', {
133+ onclick: function () {
134+ composer.replaceChild(container, composer.firstChild)
135+ container.appendChild(textarea)
136+ container.appendChild(initialButtons)
137+ }
138+ })
139+ )
140+ composer.replaceChild(preview, composer.firstChild)
141+ }
133142 }
134143 }),
135144 file_input(function (file) {
136145 files.push(file)

Built with git-ssb-web