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
17 changes: 10 additions & 7 deletions src/composables/useGetMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ export function useGetMessagesProvider() {
* @param messageId
* @param threadId
* @param highlight
* @param focus
*/
async function checkContextAndFocusMessage(token: string, messageId: number, threadId: number, highlight: boolean = false) {
async function checkContextAndFocusMessage(token: string, messageId: number, threadId: number, highlight: boolean = false, focus: boolean = true) {
if (!chatStore.hasMessage(token, { messageId, threadId })) {
// message not found in the list, need to fetch it first
await getMessageContext(token, messageId, threadId)
Expand All @@ -283,19 +284,21 @@ export function useGetMessagesProvider() {
}
}

// need some delay (next tick is too short) to be able to run
// after the browser's native "scroll to anchor" from the hash
window.setTimeout(() => {
EventBus.emit('focus-message', { messageId, highlight })
}, 2)
if (focus) {
// need some delay (next tick is too short) to be able to run
// after the browser's native "scroll to anchor" from the hash
window.setTimeout(() => {
EventBus.emit('focus-message', { messageId, highlight })
}, 2)
}
}

/**
* Update contextMessageId to the last message in the conversation
*/
async function setContextIdToBottom() {
contextMessageId.value = conversationLastMessageId.value
await checkContextAndFocusMessage(currentToken.value, contextMessageId.value, contextThreadId.value)
await checkContextAndFocusMessage(currentToken.value, contextMessageId.value, contextThreadId.value, false, false)
}

/**
Expand Down
Loading