Skip to content
Merged
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
29 changes: 14 additions & 15 deletions src/composables/useGetMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,23 +318,22 @@ export function useGetMessagesProvider() {
}

await getMessageContext(token, contextMessageId.value, contextThreadId.value)

// If last message is not present in the initial context,
// add it as most recent chat block to start long polling from it
if (conversation.value?.lastMessage && 'id' in conversation.value.lastMessage
&& !chatStore.hasMessage(token, { messageId: conversation.value.lastMessage.id })) {
await store.dispatch('processMessage', { token, message: conversation.value.lastMessage })
chatStore.processChatBlocks(token, [conversation.value.lastMessage])
}

// Fallback for sensitive and federated conversations: if there is still no chat block created,
// ensure polling starts at least from the last read message by the user
if (!chatStore.chatBlocks[token]) {
chatStore.chatBlocks[token] = [new Set([conversation.value!.lastReadMessage])]
}
} catch (exception) {
console.debug(exception)
return
}

// If last message is not present in the initial context,
// add it as most recent chat block to start long polling from it
if (conversation.value?.lastMessage && 'id' in conversation.value.lastMessage
&& !chatStore.hasMessage(token, { messageId: conversation.value.lastMessage.id })) {
await store.dispatch('processMessage', { token, message: conversation.value.lastMessage })
chatStore.processChatBlocks(token, [conversation.value.lastMessage])
}

// Fallback for sensitive and federated conversations: if there is still no chat block created,
// ensure polling starts at least from the last read message by the user
if (!chatStore.chatBlocks[token]) {
chatStore.chatBlocks[token] = [new Set([conversation.value!.lastReadMessage])]
}
} else {
await checkContextAndFocusMessage(token, contextMessageId.value, contextThreadId.value, focusMessageId !== null)
Expand Down