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
This commit is contained in:
commit
47ab2b51cf
|
@ -39,6 +39,7 @@ const PostStatusForm = {
|
|||
return {
|
||||
dropFiles: [],
|
||||
submitDisabled: false,
|
||||
error: null,
|
||||
newStatus: {
|
||||
status: statusText,
|
||||
files: []
|
||||
|
@ -90,7 +91,8 @@ const PostStatusForm = {
|
|||
media: newStatus.files,
|
||||
store: this.$store,
|
||||
inReplyToStatusId: this.replyTo
|
||||
})
|
||||
}).then((data) => {
|
||||
if (!data.error) {
|
||||
this.newStatus = {
|
||||
status: '',
|
||||
files: []
|
||||
|
@ -98,6 +100,11 @@ const PostStatusForm = {
|
|||
this.$emit('posted')
|
||||
let el = this.$el.querySelector('textarea')
|
||||
el.style.height = '16px'
|
||||
this.error = null
|
||||
} else {
|
||||
this.error = data.error
|
||||
}
|
||||
})
|
||||
},
|
||||
addMediaFile (fileInfo) {
|
||||
this.newStatus.files.push(fileInfo)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) => {
|
||||
if (!data.error) {
|
||||
store.dispatch('addNewStatuses', {
|
||||
statuses: [data],
|
||||
timeline: 'friends',
|
||||
showImmediately: true,
|
||||
noIdUpdate: true // To prevent missing notices on next pull.
|
||||
})
|
||||
}
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue