Skip to content

Commit d26bd98

Browse files
committed
Don't load more for a chat that is no longer returning additional messages
1 parent f02bccc commit d26bd98

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/components/transcript/ChatTranscriptFoundation.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ export async function reload(chatID: string, before?: string) {
1919

2020
Log.info("Received messages for chat %s from REST", chatID);
2121

22+
isDoneLedger[chatID] = recentMessages.length <= 1;
23+
2224
receiveMessages(recentMessages);
2325
}
2426

2527
const loadingLedger: Record<string, boolean | undefined> = {};
28+
const isDoneLedger: Record<string, boolean | undefined> = {};
2629

2730
export function useMessages(chatID?: string, reverse = false, injectTimestamps = true): [MessageRepresentation[], () => Promise<void>] {
2831
const allMessages = useSelector(selectMessages);
@@ -42,7 +45,7 @@ export function useMessages(chatID?: string, reverse = false, injectTimestamps =
4245
processedMessages,
4346
async () => {
4447
if (!chatID) return;
45-
if (loadingLedger[chatID]) return;
48+
if (loadingLedger[chatID] || isDoneLedger[chatID]) return;
4649
loadingLedger[chatID] = true;
4750
const lastMessage = processedMessages[reverse ? (processedMessages.length - 1) : 0];
4851
const lastMessageID = lastMessage[TIMESTAMP_ASSOCIATION] as string || lastMessage.id;

0 commit comments

Comments
 (0)