diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-02-23 19:41:35 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-23 19:41:35 +0100 |
commit | 9a1fa8643cee0b9fe9fba3fc80e7beea23174d13 (patch) | |
tree | 887a7a51997c4a78261f0c05897f3832ab871b5b | |
parent | cc6ea4afd485bc81c851e4c0b69aa39218cfb6f7 (diff) | |
parent | 96fa3b75d86ad52b71a65aedb6b2142dc865aa8d (diff) |
Merge pull request #11638 from nextcloud/fix/noid/keep-unchanged-parents
fix(messagesStore): don't update parent message in the store, if it hasn't been unchanged
-rw-r--r-- | src/store/messagesStore.js | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index 4d4d25924..84bed312b 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -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; @@ -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') @@ -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 }) }) }) |