Skip to content

Commit

Permalink
fix(chat): show spinner for uploaded files and edited messages
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Sukharev <[email protected]>

[skip ci]
  • Loading branch information
Antreesy committed Jul 11, 2024
1 parent d26413e commit 0b7ce32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export default {

data() {
return {
isEditing: false,
showReloadButton: false,
codeBlocks: null,
currentCodeBlock: null,
Expand Down Expand Up @@ -413,6 +414,7 @@ export default {
},

mounted() {
EventBus.$on('editing-message-processing', this.setIsEditing)
if (!this.containsCodeBlocks) {
return
}
Expand Down Expand Up @@ -504,7 +506,13 @@ export default {
console.error(error)
showError(t('spreed', 'Could not update the message'))
}
}
},

setIsEditing({ messageId, value }) {
if (messageId === this.id) {
this.isEditing = value
}
},
},
}
</script>
Expand Down
3 changes: 3 additions & 0 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ const actions = {
* @param {string} payload.updatedMessage The modified text of the message / file share caption
*/
async editMessage(context, { token, messageId, updatedMessage }) {
EventBus.$emit('editing-message-processing', { messageId, value: true })
const message = Object.assign({}, context.getters.message(token, messageId))
context.commit('addMessage', {
token,
Expand All @@ -670,10 +671,12 @@ const actions = {
updatedMessage,
})
context.dispatch('processMessage', { token, message: response.data.ocs.data })
EventBus.$emit('editing-message-processing', { messageId, value: false })
} catch (error) {
console.error(error)
// Restore the previous message state
context.commit('addMessage', { token, message })
EventBus.$emit('editing-message-processing', { messageId, value: false })
throw error
}
},
Expand Down

0 comments on commit 0b7ce32

Please sign in to comment.