Skip to content

Commit 78c54cf

Browse files
committed
fix(thread): extend thread blocks from message polling
Signed-off-by: Dorra Jaouad <[email protected]>
1 parent 75078cf commit 78c54cf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/stores/chat.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,16 @@ export const useChatStore = defineStore('chat', () => {
247247
const threadIds = Object.keys(threadIdSetsToUpdate)
248248
if (threadIds.length) {
249249
const chatBlockWithMergeBy: Set<number> | undefined = chatBlocks[token]?.find((set) => set.has(options.mergeBy!))
250+
const lastKnownId = getLastKnownId(token)
250251
if (chatBlockWithMergeBy) {
251-
// Populate thread blocks from chat blocks
252252
threadIds.forEach((threadId) => {
253+
if (options.mergeBy === lastKnownId && chatBlockWithMergeBy.size === 1) {
254+
// Fallback: This is either polling or posting new message in a thread view
255+
// with no other messages in main chat block
256+
threadIdSetsToUpdate[threadId].add(getLastKnownId(token, { threadId }))
257+
return
258+
}
259+
// Populate thread blocks from chat blocks
253260
for (const messageId of chatBlockWithMergeBy) {
254261
const message = store.state.messagesStore.messages[token][messageId]
255262
if (message && message.threadId === +threadId) {

0 commit comments

Comments
 (0)