diff options
author | Joas Schilling <coding@schilljs.com> | 2022-04-13 14:53:49 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-04-13 15:07:15 +0300 |
commit | 1735a7a41758134fb84cb252e46c3841dd63bff4 (patch) | |
tree | 1adb83dabf7419919e05c2153e79f26e282b9486 /src | |
parent | a0b760543daf96b9f232a96145a0351cbb888f6f (diff) |
Don't update last message of conversation with invisible messages
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/components/LeftSidebar/ConversationsList/Conversation.vue | 27 | ||||
-rw-r--r-- | src/store/conversationsStore.js | 6 |
2 files changed, 6 insertions, 27 deletions
diff --git a/src/components/LeftSidebar/ConversationsList/Conversation.vue b/src/components/LeftSidebar/ConversationsList/Conversation.vue index 66323d5d6..efffdfd83 100644 --- a/src/components/LeftSidebar/ConversationsList/Conversation.vue +++ b/src/components/LeftSidebar/ConversationsList/Conversation.vue @@ -219,39 +219,12 @@ export default { }) }, - // The messages array for this conversation - messages() { - return this.$store.getters.messages(this.item.token) - }, - // Get the last message for this conversation from the message store instead // of the conversations store. The message store is updated immediately, // while the conversations store is refreshed every 30 seconds. This allows // to display message previews in this component as soon as new messages are // received by the server. lastChatMessage() { - const lastMessageTimestamp = this.item.lastMessage ? this.item.lastMessage.timestamp : 0 - - if (Object.keys(this.messages).length > 0) { - // FIXME: risky way to get last message that assumes that keys are always sorted - // should use this.$store.getters.messagesList instead ? - const messagesKeys = Object.keys(this.messages) - const lastMessageId = messagesKeys[messagesKeys.length - 1] - - /** - * Only use the last message as lastmessage when: - * 1. It's newer than the conversations last message - * 2. It's not a command reply - * 3. It's not a temporary message starting with "/" which is a user posting a command - */ - if (this.messages[lastMessageId].timestamp > lastMessageTimestamp - && (this.messages[lastMessageId].actorType !== ATTENDEE.ACTOR_TYPE.BOTS - || this.messages[lastMessageId].actorId === ATTENDEE.CHANGELOG_BOT_ID) - && (!lastMessageId.startsWith('temp-') - || !this.messages[lastMessageId].message.startsWith('/'))) { - return this.messages[lastMessageId] - } - } return this.item.lastMessage }, diff --git a/src/store/conversationsStore.js b/src/store/conversationsStore.js index 27dd0ecbd..9f41c0961 100644 --- a/src/store/conversationsStore.js +++ b/src/store/conversationsStore.js @@ -410,9 +410,15 @@ const actions = { * Only use the last message as lastmessage when: * 1. It's not a command reply * 2. It's not a temporary message starting with "/" which is a user posting a command + * 3. It's not a reaction or deletion of a reaction + * 3. It's not a deletion of a message */ if ((lastMessage.actorType !== 'bots' || lastMessage.actorId === 'changelog') + && lastMessage.systemMessage !== 'reaction' + && lastMessage.systemMessage !== 'reaction_deleted' + && lastMessage.systemMessage !== 'reaction_revoked' + && lastMessage.systemMessage !== 'message_deleted' && ((typeof lastMessage.id.startsWith === 'function' && !lastMessage.id.startsWith('temp-')) || !lastMessage.message.startsWith('/'))) { commit('updateConversationLastMessage', { token, lastMessage }) |