Commit 4297a42a6a9727bda3d92f59855d0b7efa361c28
Disable publish button while publish is in progess
Charles Lehner committed on 8/1/2016, 10:48:36 PMParent: 7e6b652a5696469876bec17b9d29a4e649627d76
Files changed
modules/compose.js | changed |
modules/compose.js | ||
---|---|---|
@@ -48,8 +48,9 @@ | ||
48 | 48 | |
49 | 49 | var files = [] |
50 | 50 | |
51 | 51 | function publish() { |
52 | + publishBtn.disabled = true | |
52 | 53 | var content |
53 | 54 | try { |
54 | 55 | content = JSON.parse(ta.value) |
55 | 56 | } catch (err) { |
@@ -57,23 +58,26 @@ | ||
57 | 58 | meta.mentions = mentions(ta.value).concat(files) |
58 | 59 | try { |
59 | 60 | meta = prepublish(meta) |
60 | 61 | } catch (err) { |
62 | + publishBtn.disabled = false | |
61 | 63 | return alert(err.message) |
62 | 64 | } |
63 | 65 | return message_confirm(meta, done) |
64 | 66 | } |
65 | 67 | message_confirm(content, done) |
66 | 68 | |
67 | 69 | function done (err, msg) { |
70 | + publishBtn.disabled = false | |
68 | 71 | if(err) return alert(err.stack) |
69 | 72 | else ta.value = '' |
70 | 73 | |
71 | 74 | if (cb) cb(err, msg) |
72 | 75 | } |
73 | 76 | } |
74 | 77 | |
75 | 78 | |
79 | + var publishBtn = h('button', 'Publish', {onclick: publish}) | |
76 | 80 | var composer = |
77 | 81 | h('div.compose', h('div.column', ta, |
78 | 82 | accessories = h('div.row.compose__controls', |
79 | 83 | //hidden until you focus the textarea |
@@ -84,9 +88,9 @@ | ||
84 | 88 | var embed = file.type.indexOf('image/') === 0 ? '!' : '' |
85 | 89 | ta.value += embed + '['+file.name+']('+file.link+')' |
86 | 90 | console.log('added:', file) |
87 | 91 | }), |
88 | - h('button', 'Publish', {onclick: publish})) | |
92 | + publishBtn) | |
89 | 93 | ) |
90 | 94 | ) |
91 | 95 | |
92 | 96 | suggest(ta, function (word, cb) { |
Built with git-ssb-web