generated from nhcarrigan/template
feat: persist zone selection across panel navigation in sessionStorage
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
This commit is contained in:
@@ -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}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user