fix: sort injected entries by canonical defaults order after sync
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m9s
CI / Lint, Build & Test (push) Failing after 1m13s

This commit is contained in:
2026-03-23 18:18:59 -07:00
committed by Naomi Carrigan
parent e92cf3c9a1
commit a7a255dab6
3 changed files with 36 additions and 29 deletions
+7
View File
@@ -533,6 +533,13 @@ const injectMissingEntries = <T extends { id: string }>(
added = added + 1; added = added + 1;
} }
} }
const defaultOrder = new Map(defaults.map((item, index) => {
return [ item.id, index ] as const;
}));
existing.sort((itemA, itemB) => {
return (defaultOrder.get(itemA.id) ?? Number.MAX_SAFE_INTEGER)
- (defaultOrder.get(itemB.id) ?? Number.MAX_SAFE_INTEGER);
});
return added; return added;
}; };
+7 -7
View File
@@ -13,14 +13,14 @@ import { ConfirmationModal } from "../ui/confirmationModal.js";
type ActiveModal = "force-unlocks" | "hard-reset" | "sync-new-content" | null; type ActiveModal = "force-unlocks" | "hard-reset" | "sync-new-content" | null;
interface SyncNewContentResult { interface SyncNewContentResult {
achievementsAdded: number; achievementsAdded: number;
adventurersAdded: number; adventurersAdded: number;
bossesAdded: number; bossesAdded: number;
equipmentAdded: number; equipmentAdded: number;
explorationAreasAdded: number; explorationAreasAdded: number;
questsAdded: number; questsAdded: number;
upgradesAdded: number; upgradesAdded: number;
zonesAdded: number; zonesAdded: number;
} }
/** /**
+22 -22
View File
@@ -580,14 +580,14 @@ interface GameContextValue {
* @returns Counts of what was added per content type. * @returns Counts of what was added per content type.
*/ */
syncNewContent: ()=> Promise<{ syncNewContent: ()=> Promise<{
achievementsAdded: number; achievementsAdded: number;
adventurersAdded: number; adventurersAdded: number;
bossesAdded: number; bossesAdded: number;
equipmentAdded: number; equipmentAdded: number;
explorationAreasAdded: number; explorationAreasAdded: number;
questsAdded: number; questsAdded: number;
upgradesAdded: number; upgradesAdded: number;
zonesAdded: number; zonesAdded: number;
}>; }>;
/** /**
@@ -2176,14 +2176,14 @@ export const GameProvider = ({
localStorage.setItem("elysium_save_signature", data.signature); localStorage.setItem("elysium_save_signature", data.signature);
} }
return { return {
achievementsAdded: data.achievementsAdded, achievementsAdded: data.achievementsAdded,
adventurersAdded: data.adventurersAdded, adventurersAdded: data.adventurersAdded,
bossesAdded: data.bossesAdded, bossesAdded: data.bossesAdded,
equipmentAdded: data.equipmentAdded, equipmentAdded: data.equipmentAdded,
explorationAreasAdded: data.explorationAreasAdded, explorationAreasAdded: data.explorationAreasAdded,
questsAdded: data.questsAdded, questsAdded: data.questsAdded,
upgradesAdded: data.upgradesAdded, upgradesAdded: data.upgradesAdded,
zonesAdded: data.zonesAdded, zonesAdded: data.zonesAdded,
}; };
} catch (error_: unknown) { } catch (error_: unknown) {
setError( setError(
@@ -2192,14 +2192,14 @@ export const GameProvider = ({
: "Failed to sync new content", : "Failed to sync new content",
); );
return { return {
achievementsAdded: 0, achievementsAdded: 0,
adventurersAdded: 0, adventurersAdded: 0,
bossesAdded: 0, bossesAdded: 0,
equipmentAdded: 0, equipmentAdded: 0,
explorationAreasAdded: 0, explorationAreasAdded: 0,
questsAdded: 0, questsAdded: 0,
upgradesAdded: 0, upgradesAdded: 0,
zonesAdded: 0, zonesAdded: 0,
}; };
} }
}, []); }, []);
@@ -2304,6 +2304,7 @@ export const GameProvider = ({
startQuest, startQuest,
state, state,
syncError, syncError,
syncNewContent,
toggleAutoAdventurer, toggleAutoAdventurer,
toggleAutoBoss, toggleAutoBoss,
toggleAutoPrestige, toggleAutoPrestige,
@@ -2313,7 +2314,6 @@ export const GameProvider = ({
unlockedAchievements, unlockedAchievements,
unlockedCodexEntryIds, unlockedCodexEntryIds,
unlockedStoryChapterIds, unlockedStoryChapterIds,
syncNewContent,
}; };
}, [ }, [
apotheosis, apotheosis,