diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-03-14 12:17:56 +0100 |
---|---|---|
committer | Maksim Sukharev <antreesy.web@gmail.com> | 2024-03-14 12:31:36 +0100 |
commit | 1a7460bb5bca4d5a4ffea91faaa96b20419c4ee5 (patch) | |
tree | 05f807d6eefde8524aaf08f918b92d9edc64bf2e | |
parent | d0a1bca362ffa78949fb124d88715fb856a7fa39 (diff) |
fix(messages): allow to clear last read message without providing id
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
-rw-r--r-- | src/store/messagesStore.js | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js index 4c22eeede..bf1e62c7e 100644 --- a/src/store/messagesStore.js +++ b/src/store/messagesStore.js @@ -24,6 +24,7 @@ import SHA256 from 'crypto-js/sha256.js' import cloneDeep from 'lodash/cloneDeep.js' import Vue from 'vue' +import { getCapabilities } from '@nextcloud/capabilities' import { showError } from '@nextcloud/dialogs' import { @@ -49,6 +50,8 @@ import { useReactionsStore } from '../stores/reactions.js' import { useSharedItemsStore } from '../stores/sharedItems.js' import CancelableRequest from '../utils/cancelableRequest.js' +const markAsReadWithoutLast = getCapabilities()?.spreed?.features?.includes('chat-read-last') + /** * Returns whether the given message contains a mention to self, directly * or indirectly through a global mention. @@ -822,7 +825,11 @@ const actions = { */ async clearLastReadMessage(context, { token, updateVisually = false }) { const conversation = context.getters.conversation(token) - if (!conversation || !conversation.lastMessage) { + if (markAsReadWithoutLast) { + context.dispatch('updateLastReadMessage', { token, id: null, updateVisually }) + return + } + if (!conversation?.lastMessage?.id) { return } // set the id to the last message @@ -836,7 +843,7 @@ const actions = { * @param {object} context default store context; * @param {object} data the wrapping object; * @param {string} data.token the token of the conversation to be updated; - * @param {number} data.id the id of the message on which to set the read marker; + * @param {number|null} data.id the id of the message on which to set the read marker; * @param {boolean} data.updateVisually whether to also update the marker visually in the UI; */ async updateLastReadMessage(context, { token, id = 0, updateVisually = false }) { @@ -847,6 +854,7 @@ const actions = { if (id === 0) { console.warn('updateLastReadMessage: should not set read marker with id=0') + return } // optimistic early commit to avoid indicator flickering |