mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-17 21:12:20 +01:00
fix(messagesStore): mark messages to be processed from real-time
- this makes sure we do not update store with outdated information (from history fetching) Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
This commit is contained in:
parent
97b4986f24
commit
701cb83cb7
2 changed files with 10 additions and 6 deletions
|
|
@ -629,7 +629,7 @@ export function useGetMessagesProvider() {
|
|||
}
|
||||
|
||||
chatStore.processChatBlocks(token, [message], { mergeBy: chatStore.getLastKnownId(token) })
|
||||
store.dispatch('processMessage', { token, message })
|
||||
store.dispatch('processMessage', { token, message, fromRealtime: true })
|
||||
}
|
||||
|
||||
provide(GET_MESSAGES_CONTEXT_KEY, {
|
||||
|
|
|
|||
|
|
@ -455,8 +455,9 @@ const actions = {
|
|||
* @param {object} payload payload;
|
||||
* @param {string} payload.token conversation token;
|
||||
* @param {object} payload.message message object;
|
||||
* @param {boolean} [payload.fromRealtime] whether the message comes from realtime (polling or signaling)
|
||||
*/
|
||||
processMessage(context, { token, message }) {
|
||||
processMessage(context, { token, message, fromRealtime = false }) {
|
||||
const sharedItemsStore = useSharedItemsStore()
|
||||
const actorStore = useActorStore()
|
||||
const chatExtrasStore = useChatExtrasStore()
|
||||
|
|
@ -632,7 +633,7 @@ const actions = {
|
|||
|
||||
try {
|
||||
const response = await deleteMessage({ token, id })
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data })
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data, fromRealtime: true })
|
||||
return response.status
|
||||
} catch (error) {
|
||||
// Restore the previous message state
|
||||
|
|
@ -664,7 +665,7 @@ const actions = {
|
|||
messageId,
|
||||
updatedMessage,
|
||||
})
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data })
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data, fromRealtime: true })
|
||||
EventBus.emit('editing-message-processing', { messageId, value: false })
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
|
|
@ -1086,6 +1087,9 @@ const actions = {
|
|||
let countNewMessages = 0
|
||||
let hasNewMention = conversation.unreadMention
|
||||
let lastMessage = null
|
||||
// Determine if the messages are coming from realtime (polling) or not
|
||||
// Might be falsy for own messages, if send request returns before polling is closed
|
||||
const fromRealtime = !conversation?.lastMessage?.id || lastKnownMessageId >= conversation.lastMessage.id
|
||||
const chatStore = useChatStore()
|
||||
chatStore.processChatBlocks(token, response.data.ocs.data, {
|
||||
mergeBy: +lastKnownMessageId,
|
||||
|
|
@ -1099,7 +1103,7 @@ const actions = {
|
|||
const guestNameStore = useGuestNameStore()
|
||||
guestNameStore.addGuestName(message, { noUpdate: false })
|
||||
}
|
||||
context.dispatch('processMessage', { token, message })
|
||||
context.dispatch('processMessage', { token, message, fromRealtime })
|
||||
if (!lastMessage || message.id > lastMessage.id) {
|
||||
if (!message.systemMessage) {
|
||||
if (actorId !== message.actorId || actorType !== message.actorType) {
|
||||
|
|
@ -1249,7 +1253,7 @@ const actions = {
|
|||
chatStore.processChatBlocks(token, [response.data.ocs.data], {
|
||||
mergeBy: conversationLastMessageId,
|
||||
})
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data })
|
||||
context.dispatch('processMessage', { token, message: response.data.ocs.data, fromRealtime: true })
|
||||
}
|
||||
|
||||
return response
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue