Skip to content

Commit

Permalink
Fix context check in loadThreadMessages
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles committed Dec 28, 2023
1 parent 10910fc commit 8594d2a
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions frontend/openchat-client/src/openchat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2349,9 +2349,9 @@ export class OpenChat extends OpenChatAgentWorker {
return Promise.resolve();
}

const context = this._liveState.selectedMessageContext;
const context = { chatId, threadRootMessageIndex };

if (context?.threadRootMessageIndex === undefined) return;
if (!messageContextsEqual(context, this._liveState.selectedMessageContext)) return;

const eventsResponse = await this.sendRequest({
kind: "chatEvents",
Expand All @@ -2364,11 +2364,6 @@ export class OpenChat extends OpenChatAgentWorker {
latestKnownUpdate: chat.lastUpdated,
});

if (!messageContextsEqual(context, this._liveState.selectedMessageContext)) {
// the selected thread has changed while we were loading the messages
return;
}

if (eventsResponse !== undefined && eventsResponse !== "events_failed") {
if (clearEvents) {
threadServerEventsStore.set([]);
Expand Down

0 comments on commit 8594d2a

Please sign in to comment.