Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2021-03-08 18:04:16 +0300
committerVincent Petry <vincent@nextcloud.com>2021-03-08 18:22:17 +0300
commitc26d5e32d2a0d9edb52f360095aae3c60d707163 (patch)
treeccfe6b8508a05e0a7eed16355de71e3a9102bbd6 /src/store/messagesStore.js
parent7d4d6fbf2f07184df9021cbfafe3732ba95e86da (diff)
Update read marker UI when posting + tweaks
When posting new messages, the read marker UI will also be updated. Fixed read marker update when scrolled to bottom. Fixed warnings related to temporary message id being a string. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'src/store/messagesStore.js')
-rw-r--r--src/store/messagesStore.js30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/store/messagesStore.js b/src/store/messagesStore.js
index 8c6c293a4..6d8564de8 100644
--- a/src/store/messagesStore.js
+++ b/src/store/messagesStore.js
@@ -358,24 +358,48 @@ const actions = {
context.commit('deleteMessages', token)
},
- async clearLastReadMessage(context, { token }) {
+ /**
+ * Clears the last read message marker by moving it to the last message
+ * in the conversation.
+ *
+ * @param {object} context default store context;
+ * @param {object} token the token of the conversation to be updated;
+ * @param {bool} updateVisually whether to also clear the marker visually in the UI;
+ */
+ async clearLastReadMessage(context, { token, updateVisually = false }) {
const conversation = context.getters.conversations[token]
if (!conversation || !conversation.lastMessage) {
return
}
// set the id to the last message
- context.dispatch('updateLastReadMessage', { token, id: conversation.lastMessage.id })
+ context.dispatch('updateLastReadMessage', { token, id: conversation.lastMessage.id, updateVisually: updateVisually })
context.dispatch('markConversationRead', token)
},
- async updateLastReadMessage(context, { token, id = 0 }) {
+ /**
+ * Updates the last read message in the store and also in the backend.
+ * Optionally also updated the marker visually in the UI if specified.
+ *
+ * @param {object} context default store context;
+ * @param {object} token the token of the conversation to be updated;
+ * @param {number} id the id of the message on which to set the read marker;
+ * @param {bool} updateVisually whether to also update the marker visually in the UI;
+ */
+ async updateLastReadMessage(context, { token, id = 0, updateVisually = false }) {
const conversation = Object.assign({}, context.getters.conversations[token])
if (!conversation || conversation.lastReadMessage === id) {
return
}
+ if (id === 0) {
+ console.warn('updateLastReadMessage: should not set read marker with id=0')
+ }
+
// optimistic early commit to avoid indicator flickering
context.commit('updateConversationLastReadMessage', { token, lastReadMessage: id })
+ if (updateVisually) {
+ context.commit('setVisualLastReadMessageId', { token, id })
+ }
await updateLastReadMessage(token, id)
},
}