Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(messagesStore): don't update parent message in the store, if it hasn't been unchanged #11638

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
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
9 changes: 4 additions & 5 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,7 @@ const actions = {
/**
* Adds message to the store.
*
* If the message has a parent message object,
* first it adds the parent to the store.
* If the message has a parent message presented in the store, updates it as well.
*
* @param {object} context default store context;
* @param {object} payload payload;
Expand All @@ -533,9 +532,9 @@ const actions = {
|| message.systemMessage === 'reaction_deleted'
|| message.systemMessage === 'reaction_revoked'
|| message.systemMessage === 'message_edited')) {
// If parent message is presented in store already, we update it
// If parent message is presented in store and is different, we update it
const parentInStore = context.getters.message(token, message.parent.id)
if (Object.keys(parentInStore).length !== 0) {
if (Object.keys(parentInStore).length !== 0 && JSON.stringify(parentInStore) !== JSON.stringify(message.parent)) {
context.commit('addMessage', { token, message: message.parent })
if (message.systemMessage === 'message_edited') {
EventBus.$emit('message-edited')
Expand All @@ -553,7 +552,7 @@ const actions = {
// Check existing messages for having a deleted message as parent, and update them
if (message.systemMessage === 'message_deleted') {
context.getters.messagesList(token)
.filter(storedMessage => storedMessage.parent?.id === message.parent.id)
.filter(storedMessage => storedMessage.parent?.id === message.parent.id && JSON.stringify(storedMessage.parent) !== JSON.stringify(message.parent))
.forEach(storedMessage => {
context.commit('addMessage', { token, message: Object.assign({}, storedMessage, { parent: message.parent }) })
})
Expand Down
Loading