fix(chat): isolate pending flows and cancel stale requests
This commit is contained in:
@@ -79,6 +79,7 @@ export function useChatUnlockCoordinator({
|
||||
const trackedPaywallRef = useRef<string | null>(null);
|
||||
const chatState = useChatSelector(
|
||||
(state) => ({
|
||||
characterId: state.context.characterId,
|
||||
historyLoaded: state.context.historyLoaded,
|
||||
isUnlockingHistory: state.matches({ userSession: "unlockingHistory" }),
|
||||
lockedHistoryCount: state.context.lockedHistoryCount,
|
||||
@@ -125,7 +126,7 @@ export function useChatUnlockCoordinator({
|
||||
let cancelled = false;
|
||||
|
||||
const resumePendingUnlock = async () => {
|
||||
const pending = await peekPendingChatUnlock();
|
||||
const pending = await peekPendingChatUnlock(chatState.characterId);
|
||||
if (
|
||||
cancelled ||
|
||||
!pending ||
|
||||
@@ -138,7 +139,7 @@ export function useChatUnlockCoordinator({
|
||||
return;
|
||||
}
|
||||
|
||||
const consumed = await consumePendingChatUnlock();
|
||||
const consumed = await consumePendingChatUnlock(chatState.characterId);
|
||||
if (cancelled || !consumed) return;
|
||||
|
||||
chatDispatch({
|
||||
@@ -157,6 +158,7 @@ export function useChatUnlockCoordinator({
|
||||
};
|
||||
}, [
|
||||
chatDispatch,
|
||||
chatState.characterId,
|
||||
chatState.historyLoaded,
|
||||
defaultReturnUrl,
|
||||
enabled,
|
||||
|
||||
Reference in New Issue
Block a user