git ssb

10+

Matt McKegg / patchwork



Commit dbe5c71a464700476f4e3d9a8badd4ce60fcec4d

compose: disable button and text while publishing

Matt McKegg committed on 3/13/2017, 11:30:10 AM
Parent: abf4308e0df5e58e0bc15bbcc0810ead0e7391f0

Files changed

modules/message/html/compose.jschanged
styles/button.mcsschanged
styles/compose.mcsschanged
modules/message/html/compose.jsView
@@ -25,8 +25,9 @@
2525 var files = []
2626 var filesById = {}
2727 var focused = Value(false)
2828 var hasContent = Value(false)
29 + var publishing = Value(false)
2930 var getProfileSuggestions = api.profile.async.suggest()
3031 var getChannelSuggestions = api.channel.async.suggest()
3132
3233 var blurTimeout = null
@@ -47,8 +48,9 @@
4748 clearTimeout(blurTimeout)
4849 blurTimeout = setTimeout(() => focused.set(false), 200)
4950 },
5051 'ev-focus': send(focused.set, true),
52 + disabled: publishing,
5153 placeholder
5254 })
5355
5456 var fileInput = api.blob.html.input(file => {
@@ -64,9 +66,12 @@
6466 fileInput.onclick = function () {
6567 hasContent.set(true)
6668 }
6769
68- var publishBtn = h('button', { 'ev-click': publish }, 'Publish')
70 + var publishBtn = h('button', {
71 + 'ev-click': publish,
72 + disabled: publishing
73 + }, when(publishing, 'Publishing...', 'Publish'))
6974
7075 var actions = h('section.actions', [
7176 fileInput,
7277 publishBtn
@@ -110,9 +115,9 @@
110115
111116 // scoped
112117
113118 function publish () {
114- publishBtn.disabled = true
119 + publishing.set(true)
115120
116121 meta = extend(resolve(meta), {
117122 text: textArea.value,
118123 mentions: mentions(textArea.value).map(mention => {
@@ -130,17 +135,17 @@
130135 if (typeof prepublish === 'function') {
131136 meta = prepublish(meta)
132137 }
133138 } catch (err) {
134- publishBtn.disabled = false
139 + publishing.set(false)
135140 if (cb) cb(err)
136141 else throw err
137142 }
138143
139144 return api.message.async.publish(meta, done)
140145
141146 function done (err, msg) {
142- publishBtn.disabled = false
147 + publishing.set(false)
143148 if (err) throw err
144149 else if (msg) textArea.value = ''
145150 if (cb) cb(err, msg)
146151 }
styles/button.mcssView
@@ -19,8 +19,14 @@
1919 :active {
2020 background-color: #DDD !important
2121 }
2222
23 + [disabled] {
24 + color: #999797 !important;
25 + background: #e3e2e2 !important;
26 + border-color: #DDD !important;
27 + }
28 +
2329 -pub {
2430 color: #6a7e6a;
2531 background-color: #ecfff0;
2632 border-color: #8ba289;
styles/compose.mcssView
@@ -12,8 +12,12 @@
1212 textarea {
1313 background: transparent
1414 border: none
1515 padding: 10px
16 + [disabled] {
17 + color: #AAA;
18 + background: #ebf7ee;
19 + }
1620 }
1721
1822 section.actions {
1923 display: flex

Built with git-ssb-web