5 Commits

Author SHA1 Message Date
hikari c3e85c3768 feat: persist exploration zone selection in sessionStorage
CI / Lint, Build & Test (pull_request) Successful in 1m16s
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m17s
Applies the same sticky-zone pattern as the boss and quest panels.
The handleZoneSelect wrapper already existed — it just needed to write
to sessionStorage alongside updating state, and the useState initialiser
needed to read from sessionStorage on mount.
2026-03-09 22:15:38 -07:00
hikari 2c16736bdf fix: use item name as key for equipped items list
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m4s
CI / Lint, Build & Test (pull_request) Successful in 1m8s
item.type only has three possible values (weapon/armour/trinket).
Using it as a React key is safe in practice because the equipment system
enforces one item per slot, but item.name is a stable, semantically
correct unique identifier that does not rely on that invariant.
2026-03-09 22:12:42 -07:00
hikari 0dc572c6fa fix: use stable unique keys for quest reward list
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m3s
CI / Lint, Build & Test (pull_request) Successful in 1m8s
The previous key `${reward.type}-${amount ?? ""}` collapsed to
"adventurer-" for every adventurer-unlock reward (which carries no
amount), producing duplicate-key React warnings on every render tick.
Because console.error is forwarded to the backend telemetry service,
this caused continuous email alerts.

The key now uses targetId (present on adventurer and upgrade rewards)
first, falls back to amount (present on gold/essence/crystal rewards),
and uses the map index only as a last resort.
2026-03-09 22:07:36 -07:00
hikari 9fcc5bb836 feat: persist zone selection across panel navigation in sessionStorage
Security Scan and Upload / Security & DefectDojo Upload (pull_request) Successful in 1m2s
CI / Lint, Build & Test (pull_request) Successful in 1m7s
Both the boss panel and the quest panel now read their active zone from
sessionStorage on mount and write back to it whenever the user selects
a new zone. The stored selections are cleared automatically when the
session ends, and fall back to verdant_vale when no stored value exists.

Closes #36
2026-03-09 22:02:56 -07:00
hikari fc93efd245 feat: persist adventure multiplier selection in localStorage
Reads the saved batch-size preference on mount and writes it back to
localStorage on every selection change, so the chosen multiplier
survives page refreshes. Falls back to 1 when no stored value is found
or the value is unrecognisable.

Closes #35
2026-03-09 22:02:52 -07:00
5 changed files with 54 additions and 9 deletions
@@ -16,6 +16,31 @@ import type { Adventurer } from "@elysium/types";
type BatchSize = 1 | 5 | 10 | 25 | 100 | "max";
const batchOptions: Array<BatchSize> = [ 1, 5, 10, 25, 100, "max" ];
/**
* Parses a localStorage string back into a valid BatchSize, defaulting to 1.
* @param stored - The raw string from localStorage (or null if absent).
* @returns A valid BatchSize value.
*/
const parseBatchSize = (stored: string | null): BatchSize => {
if (stored === "max") {
return "max";
}
const numeric = Number(stored);
if (numeric === 5) {
return 5;
}
if (numeric === 10) {
return 10;
}
if (numeric === 25) {
return 25;
}
if (numeric === 100) {
return 100;
}
return 1;
};
/**
* Computes the total cost to buy a batch of adventurers.
* @param adventurer - The adventurer to buy.
@@ -148,7 +173,9 @@ const AdventurerCard = ({
const AdventurerPanel = (): JSX.Element => {
const { state, formatNumber } = useGame();
const [ showLocked, setShowLocked ] = useState(true);
const [ batchSize, setBatchSize ] = useState<BatchSize>(1);
const [ batchSize, setBatchSize ] = useState<BatchSize>(() => {
return parseBatchSize(localStorage.getItem("elysium_batch_size"));
});
if (state === null) {
return (
@@ -196,6 +223,7 @@ const AdventurerPanel = (): JSX.Element => {
{batchOptions.map((option) => {
function handleBatchSelect(): void {
setBatchSize(option);
localStorage.setItem("elysium_batch_size", String(option));
}
return (
<button
+9 -2
View File
@@ -239,7 +239,9 @@ const BossPanel = (): JSX.Element => {
const [ challengingBossId, setChallengingBossId ] = useState<string | null>(
null,
);
const [ activeZoneId, setActiveZoneId ] = useState("verdant_vale");
const [ activeZoneId, setActiveZoneId ] = useState(() => {
return sessionStorage.getItem("elysium_boss_zone") ?? "verdant_vale";
});
const [ showLocked, setShowLocked ] = useState(true);
if (state === null) {
@@ -317,6 +319,11 @@ const BossPanel = (): JSX.Element => {
}
}
function handleZoneSelect(zoneId: string): void {
setActiveZoneId(zoneId);
sessionStorage.setItem("elysium_boss_zone", zoneId);
}
function handleToggle(): void {
setShowLocked((current) => {
return !current;
@@ -374,7 +381,7 @@ const BossPanel = (): JSX.Element => {
<ZoneSelector
activeZoneId={activeZoneId}
onSelectZone={setActiveZoneId}
onSelectZone={handleZoneSelect}
zones={zones}
/>
@@ -243,7 +243,7 @@ const CharacterPage = ({ discordId }: CharacterPageProperties): JSX.Element => {
return (
<div
className="character-page-equipment-item"
key={item.type}
key={item.name}
>
<div className="character-page-equipment-header">
<span className="character-page-equipment-slot">
@@ -67,7 +67,9 @@ interface CollectResult {
const ExplorationPanel = (): JSX.Element => {
const { state, startExploration, collectExploration, formatNumber }
= useGame();
const [ activeZoneId, setActiveZoneId ] = useState("verdant_vale");
const [ activeZoneId, setActiveZoneId ] = useState(() => {
return sessionStorage.getItem("elysium_explore_zone") ?? "verdant_vale";
});
const [ pendingAreaId, setPendingAreaId ] = useState<string | null>(null);
const [ lastResult, setLastResult ] = useState<CollectResult | null>(null);
@@ -116,6 +118,7 @@ const ExplorationPanel = (): JSX.Element => {
function handleZoneSelect(id: string): void {
setActiveZoneId(id);
setLastResult(null);
sessionStorage.setItem("elysium_explore_zone", id);
}
const goldChange = lastResult?.response.event?.goldChange ?? 0;
+11 -4
View File
@@ -108,9 +108,9 @@ const QuestCard = ({
</p>
}
<div className="quest-rewards">
{quest.rewards.map((reward) => {
{quest.rewards.map((reward, rewardIndex) => {
return (
<span className="reward-tag" key={`${reward.type}-${String(reward.amount ?? "")}`}>
<span className="reward-tag" key={`${reward.type}-${reward.targetId ?? String(reward.amount ?? rewardIndex)}`}>
{reward.type === "gold"
&& `🪙 ${formatNumber(reward.amount ?? 0)}`}
{reward.type === "essence"
@@ -184,7 +184,9 @@ const QuestCard = ({
*/
const QuestPanel = (): JSX.Element => {
const { state, toggleAutoQuest } = useGame();
const [ activeZoneId, setActiveZoneId ] = useState("verdant_vale");
const [ activeZoneId, setActiveZoneId ] = useState(() => {
return sessionStorage.getItem("elysium_quest_zone") ?? "verdant_vale";
});
const [ showLocked, setShowLocked ] = useState(true);
if (state === null) {
@@ -243,6 +245,11 @@ const QuestPanel = (): JSX.Element => {
}
}
function handleZoneSelect(zoneId: string): void {
setActiveZoneId(zoneId);
sessionStorage.setItem("elysium_quest_zone", zoneId);
}
function handleToggle(): void {
setShowLocked((current) => {
return !current;
@@ -285,7 +292,7 @@ const QuestPanel = (): JSX.Element => {
<ZoneSelector
activeZoneId={activeZoneId}
onSelectZone={setActiveZoneId}
onSelectZone={handleZoneSelect}
zones={zones}
/>