From bbd6a86a693d48142597868b41ef76138f8ee26c Mon Sep 17 00:00:00 2001 From: DorraJaouad Date: Wed, 27 Mar 2024 10:50:14 +0100 Subject: [PATCH] chore(MessagesStore): adjust fallback displayable messages Signed-off-by: DorraJaouad --- src/store/messagesStore.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index b9d8b3895ee1..40d2ca94e1ea 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -224,16 +224,14 @@ const getters = { return null } - const displayableMessages = getters.messagesList(token).filter(message => { + return getters.messagesList(token).find(message => { return message.id >= readMessageId - && !('' + message.id).startsWith('temp-') - }) - - if (displayableMessages.length) { - return displayableMessages.shift().id - } - - return null + && !String(message.id).startsWith('temp-') + && message.systemMessage !== 'reaction' + && message.systemMessage !== 'reaction_deleted' + && message.systemMessage !== 'reaction_revoked' + && message.systemMessage !== 'poll_voted' + })?.id }, getFirstDisplayableMessageIdBeforeReadMarker: (state, getters) => (token, readMessageId) => { @@ -241,16 +239,14 @@ const getters = { return null } - const displayableMessages = getters.messagesList(token).filter(message => { + return getters.messagesList(token).slice().reverse().find(message => { return message.id < readMessageId - && !('' + message.id).startsWith('temp-') - }) - - if (displayableMessages.length) { - return displayableMessages.pop().id - } - - return null + && !String(message.id).startsWith('temp-') + && message.systemMessage !== 'reaction' + && message.systemMessage !== 'reaction_deleted' + && message.systemMessage !== 'reaction_revoked' + && message.systemMessage !== 'poll_voted' + })?.id }, isSendingMessages: (state) => {