Every Sokko TCG section now offers the top bar's toolbox button. Instead of linking a toolbox, the drawer lists all toolboxes (linked to a game or not) as wide rows with a large cover, opens the one chosen, and remembers it on the device. Memos and alerts follow the toolbox shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1,001 B
JavaScript
27 lines
1,001 B
JavaScript
// Rôle : retient, sur cet appareil, la toolbox choisie dans le tiroir de Sokko TCG, pour la rouvrir directement à la visite suivante.
|
|
// Une préférence d'affichage, pas une donnée de toolbox : elle n'entre ni dans les liaisons ni dans les exports.
|
|
import { useCallback, useState } from "react";
|
|
|
|
const CARDS_TOOLBOX_STORAGE_KEY = "sokkog:cards-toolbox";
|
|
|
|
function readChoice() {
|
|
try {
|
|
return globalThis.localStorage?.getItem(CARDS_TOOLBOX_STORAGE_KEY) || "";
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|
|
|
|
export function useCardsToolboxChoice() {
|
|
const [toolboxId, setToolboxId] = useState(readChoice);
|
|
const choose = useCallback((nextId) => {
|
|
setToolboxId(nextId || "");
|
|
try {
|
|
if (nextId) globalThis.localStorage?.setItem(CARDS_TOOLBOX_STORAGE_KEY, nextId);
|
|
else globalThis.localStorage?.removeItem(CARDS_TOOLBOX_STORAGE_KEY);
|
|
} catch {
|
|
// Stockage refusé (navigation privée, quota) : le choix vaut pour la session.
|
|
}
|
|
}, []);
|
|
return [toolboxId, choose];
|
|
}
|