commit: 47ab2b51cf174bd464724a8e745a6465c4da99e2
parent: fb3408d64f361417c31f7fde4d206eab3e17acae
Author: lambadalambda <gitgud@rogerbraun.net>
Date: Sun, 20 Aug 2017 08:14:27 -0400
Merge branch 'feature/post-status-errors' into 'develop'
Add error message in post status form when failing to post
Closes #24
See merge request !97
Diffstat:
3 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js
@@ -39,6 +39,7 @@ const PostStatusForm = {
return {
dropFiles: [],
submitDisabled: false,
+ error: null,
newStatus: {
status: statusText,
files: []
@@ -90,14 +91,20 @@ const PostStatusForm = {
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.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
@@ -19,6 +19,9 @@
<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>
</div>
+ <div class='error' v-if="error">
+ Error: {{ error }}
+ </div>
<div class="attachments">
<div class="attachment" v-for="file in newStatus.files">
<i class="fa icon-cancel" @click="removeMediaFile(file)"></i>
@@ -61,6 +64,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;
diff --git a/src/services/status_poster/status_poster.service.js b/src/services/status_poster/status_poster.service.js
@@ -7,12 +7,15 @@ const postStatus = ({ store, status, media = [], inReplyToStatusId = undefined }
return apiService.postStatus({credentials: store.state.users.currentUser.credentials, status, mediaIds, inReplyToStatusId})
.then((data) => data.json())
.then((data) => {
- store.dispatch('addNewStatuses', {
- statuses: [data],
- timeline: 'friends',
- showImmediately: true,
- noIdUpdate: true // To prevent missing notices on next pull.
- })
+ if (!data.error) {
+ store.dispatch('addNewStatuses', {
+ statuses: [data],
+ timeline: 'friends',
+ showImmediately: true,
+ noIdUpdate: true // To prevent missing notices on next pull.
+ })
+ }
+ return data
})
}