Skip to content

Commit

Permalink
chore(MessagesStore): adjust fallback displayable messages
Browse files Browse the repository at this point in the history
Signed-off-by: DorraJaouad <dorra.jaoued7@gmail.com>
  • Loading branch information
DorraJaouad committed Mar 27, 2024
1 parent 785a5ee commit f3da3a9
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,33 +224,29 @@ 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) => {
if (!state.messages[token]) {
return null
}

const displayableMessages = getters.messagesList(token).filter(message => {
return getters.messagesList(token).findLast(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) => {
Expand Down

0 comments on commit f3da3a9

Please sign in to comment.