Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(MessagesList): fix fetching messages completion when there is no … #13834

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/components/MessagesList/MessagesList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import TransitionWrapper from '../UIShared/TransitionWrapper.vue'

import { useDocumentVisibility } from '../../composables/useDocumentVisibility.ts'
import { useIsInCall } from '../../composables/useIsInCall.js'
import { ATTENDEE, CHAT, CONVERSATION } from '../../constants.js'
import { ATTENDEE, CHAT, CONVERSATION, MESSAGE } from '../../constants.js'
import { EventBus } from '../../services/EventBus.ts'
import { useChatExtrasStore } from '../../stores/chatExtras.js'
import { debugTimer } from '../../utils/debugTimer.ts'
Expand Down Expand Up @@ -670,9 +670,10 @@ export default {
}
this.$store.dispatch('setFirstKnownMessageId', { token, id: startingMessageId })
this.$store.dispatch('setLastKnownMessageId', { token, id: startingMessageId })

// If MESSAGE.CHAT_BEGIN_ID we need to get the context from the beginning
// using 0 as the API does not support negative values
// Get chat messages before last read message and after it
await this.getMessageContext(token, startingMessageId)
await this.getMessageContext(token, startingMessageId !== MESSAGE.CHAT_BEGIN_ID ? startingMessageId : 0)
} catch (exception) {
console.debug(exception)
// Request was cancelled, stop getting preconditions and restore initial state
Expand Down
5 changes: 5 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ export const ATTENDEE = {
CHANGELOG_BOT_ID: 'changelog',
}

export const MESSAGE = {
CHAT_BEGIN_ID: -2,
DorraJaouad marked this conversation as resolved.
Show resolved Hide resolved
CHAT_MIGRATION_ID: -1,
}

export const PARTICIPANT = {
CALL_FLAG: {
DISCONNECTED: 0,
Expand Down
6 changes: 4 additions & 2 deletions src/store/messagesStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
ATTENDEE,
CHAT,
CONVERSATION,
MESSAGE,
} from '../constants.js'
import { hasTalkFeature } from '../services/CapabilitiesManager.ts'
import { fetchNoteToSelfConversation } from '../services/conversationsService.js'
Expand Down Expand Up @@ -967,7 +968,7 @@ const actions = {
}
context.dispatch('processMessage', { token, message })
newestKnownMessageId = Math.max(newestKnownMessageId, message.id)
oldestKnownMessageId = Math.min(oldestKnownMessageId, message.id)
oldestKnownMessageId = oldestKnownMessageId === 0 ? message.id : Math.min(oldestKnownMessageId, message.id)

if (message.id <= messageId
&& message.systemMessage !== 'reaction'
Expand All @@ -979,7 +980,8 @@ const actions = {
}
})

if (!context.getters.getFirstKnownMessageId(token) || oldestKnownMessageId < context.getters.getFirstKnownMessageId(token)) {
if (!context.getters.getFirstKnownMessageId(token) || oldestKnownMessageId < context.getters.getFirstKnownMessageId(token)
|| context.getters.getFirstKnownMessageId(token) === MESSAGE.CHAT_BEGIN_ID) {
context.dispatch('setFirstKnownMessageId', {
token,
id: oldestKnownMessageId,
Expand Down
Loading