generated from nhcarrigan/template
fix: delay boss lore toasts until battle animation reveals result
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -455,6 +455,11 @@ interface GameContextValue {
|
||||
*/
|
||||
dismissCodexEntry: (id: string)=> void;
|
||||
|
||||
/**
|
||||
* Flush pending boss lore codex toasts — call after the battle animation reveals the result.
|
||||
*/
|
||||
flushBossLoreToasts: ()=> void;
|
||||
|
||||
/**
|
||||
* Perform a transcendence — nuclear reset, earning echoes.
|
||||
*/
|
||||
@@ -613,6 +618,7 @@ export const GameProvider = ({
|
||||
Array<string>
|
||||
>([]);
|
||||
const codexProcessedReference = useRef<Set<string>>(new Set());
|
||||
const pendingBossCodexIdsReference = useRef<Array<string>>([]);
|
||||
const [ unlockedStoryChapterIds, setUnlockedStoryChapterIds ] = useState<
|
||||
Array<string>
|
||||
>([]);
|
||||
@@ -880,12 +886,30 @@ export const GameProvider = ({
|
||||
};
|
||||
});
|
||||
if (!isFirstRun) {
|
||||
setUnlockedCodexEntryIds((previous) => {
|
||||
return [ ...previous, ...addedIds ];
|
||||
const bossIds = addedIds.filter((id) => {
|
||||
return id.startsWith("boss_");
|
||||
});
|
||||
const otherIds = addedIds.filter((id) => {
|
||||
return !id.startsWith("boss_");
|
||||
});
|
||||
if (bossIds.length > 0) {
|
||||
if (battleResult === null) {
|
||||
otherIds.push(...bossIds);
|
||||
} else {
|
||||
pendingBossCodexIdsReference.current = [
|
||||
...pendingBossCodexIdsReference.current,
|
||||
...bossIds,
|
||||
];
|
||||
}
|
||||
}
|
||||
if (otherIds.length > 0) {
|
||||
setUnlockedCodexEntryIds((previous) => {
|
||||
return [ ...previous, ...otherIds ];
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}, [ state ]);
|
||||
}, [ battleResult, state ]);
|
||||
|
||||
// Detect newly unlocked story chapters
|
||||
useEffect(() => {
|
||||
@@ -1836,6 +1860,16 @@ export const GameProvider = ({
|
||||
});
|
||||
}, []);
|
||||
|
||||
const flushBossLoreToasts = useCallback(() => {
|
||||
const pending = pendingBossCodexIdsReference.current;
|
||||
if (pending.length > 0) {
|
||||
pendingBossCodexIdsReference.current = [];
|
||||
setUnlockedCodexEntryIds((previous) => {
|
||||
return [ ...previous, ...pending ];
|
||||
});
|
||||
}
|
||||
}, []);
|
||||
|
||||
const dismissStoryChapter = useCallback((id: string) => {
|
||||
setUnlockedStoryChapterIds((previous) => {
|
||||
return previous.filter((chapter) => {
|
||||
@@ -1935,6 +1969,7 @@ export const GameProvider = ({
|
||||
equipItem,
|
||||
error,
|
||||
failedQuestToasts,
|
||||
flushBossLoreToasts,
|
||||
forceSync,
|
||||
formatNumber,
|
||||
handleClick,
|
||||
@@ -2001,6 +2036,7 @@ export const GameProvider = ({
|
||||
enableSounds,
|
||||
equipItem,
|
||||
error,
|
||||
flushBossLoreToasts,
|
||||
forceSync,
|
||||
handleClick,
|
||||
isLoading,
|
||||
|
||||
Reference in New Issue
Block a user