diff options
Diffstat (limited to 'src/components/post_status_form')
| -rw-r--r-- | src/components/post_status_form/post_status_form.js | 25 | ||||
| -rw-r--r-- | src/components/post_status_form/post_status_form.vue | 13 |
2 files changed, 30 insertions, 8 deletions
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index c0970263..af5b81d4 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -39,6 +39,8 @@ const PostStatusForm = { return { dropFiles: [], submitDisabled: false, + error: null, + posting: false, newStatus: { status: statusText, files: [] @@ -85,19 +87,28 @@ const PostStatusForm = { this.caret = selectionStart }, postStatus (newStatus) { + if (this.posting) { return } + this.posting = true statusPoster.postStatus({ status: newStatus.status, media: newStatus.files, store: this.$store, inReplyToStatusId: this.replyTo + }).then((data) => { + if (!data.error) { + this.newStatus = { + status: '', + files: [] + } + this.$emit('posted') + let el = this.$el.querySelector('textarea') + el.style.height = '16px' + this.error = null + } else { + this.error = data.error + } + this.posting = false }) - this.newStatus = { - status: '', - files: [] - } - this.$emit('posted') - let el = this.$el.querySelector('textarea') - el.style.height = '16px' }, addMediaFile (fileInfo) { this.newStatus.files.push(fileInfo) diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index a17d6479..e775c45e 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -17,7 +17,11 @@ </div> <div class='form-bottom'> <media-upload @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="enableSubmit" :drop-files="dropFiles"></media-upload> - <button :disabled="submitDisabled" type="submit" class="btn btn-default base05 base01-background">Submit</button> + <button v-if="posting" disabled class="btn btn-default base05 base01-background">Posting</button> + <button v-else :disabled="submitDisabled" type="submit" class="btn btn-default base05 base01-background">Submit</button> + </div> + <div class='error' v-if="error"> + Error: {{ error }} </div> <div class="attachments"> <div class="attachment" v-for="file in newStatus.files"> @@ -61,6 +65,13 @@ width: 10em; } } + .error { + border-radius: 5px; + text-align: center; + background-color: rgba(255, 48, 16, 0.65); + padding: 0.25em; + margin: 0.35em; + } .attachments { padding: 0 0.5em; |
