Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
In case of error when sending message, revert
Whenever an error occurs when sending a message, the message is now put
back into the field and the temporary one is removed from the messages list.

Whenever a conversation was locked or lobby was enabled concurrently,
posting a message before the UI update could result in a 403 or 412 error.
These now display a proper message to inform about missing permissions.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Oct 13, 2020
commit 03128181d193f8a76d11d982954e92bb584868a2
25 changes: 23 additions & 2 deletions src/components/NewMessageForm/NewMessageForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ export default {
* Sends the new message
*/
async handleSubmit() {

if (this.parsedText !== '') {
const oldMessage = this.parsedText
const temporaryMessage = createTemporaryMessage(this.parsedText, this.token)
this.$store.dispatch('addTemporaryMessage', temporaryMessage)
this.text = ''
Expand Down Expand Up @@ -270,7 +270,28 @@ export default {
})
}
} catch (error) {
console.debug(`error while submitting message ${error}`)
let statusCode = null
console.debug(`error while submitting message ${error}`, error)
if (error.isAxiosError) {
statusCode = error.response.status
}
// 403 when room is read-only, 412 when switched to lobby mode
if (statusCode === 403 || statusCode === 412) {
OC.Notification.show(
t('spreed', 'No permission to post messages in this room'),
{ type: 'error' }
)
} else {
OC.Notification.show(
t('spreed', 'Could not post message: {errorMessage}', { errorMessage: error.message || error }),
{ type: 'error' }
)
}

// restore message to allow re-sending
this.$store.dispatch('deleteMessage', temporaryMessage)
this.text = oldMessage
this.parsedText = oldMessage
}
}
},
Expand Down