Fix toolbox tutorial state across navigation
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
Some checks failed
Deploy Sokko G / deploy (push) Failing after 2s
This commit is contained in:
parent
75d4d99a87
commit
898fd5286f
5 changed files with 111 additions and 11 deletions
|
|
@ -181,12 +181,17 @@ function shouldShowTutorial(toolbox, pendingTutorialToolboxId) {
|
|||
|
||||
function ToolboxView({ siteContent, toolbox, toolboxGame, embedded, actions, storageUsage, storageReady = true, getModuleData, updateToolbox, updateModuleData, addImageFiles, pendingTutorialToolboxId = "", setPendingTutorialToolboxId }) {
|
||||
const toolboxId = toolbox.id;
|
||||
const toolboxTutorial = toolbox.tutorial;
|
||||
const moduleColumns = embedded || Number(toolbox.moduleColumns) === 1 ? 1 : 2;
|
||||
const toolboxGameCover = getGameCardCover(toolboxGame);
|
||||
const moduleText = siteContent.toolboxes.modules;
|
||||
const [showTutorial, setShowTutorial] = useState(() => shouldShowTutorial(toolbox, pendingTutorialToolboxId));
|
||||
const currentToolboxIdRef = useRef(toolboxId);
|
||||
const tutorialRequested = shouldShowTutorial(toolbox, pendingTutorialToolboxId);
|
||||
const [previousTutorial, setPreviousTutorial] = useState({ toolboxId, requested: tutorialRequested });
|
||||
// Consommer la demande de lancement ne doit pas interrompre la visite en cours.
|
||||
if (previousTutorial.toolboxId !== toolboxId || previousTutorial.requested !== tutorialRequested) {
|
||||
setPreviousTutorial({ toolboxId, requested: tutorialRequested });
|
||||
if (previousTutorial.toolboxId !== toolboxId || tutorialRequested) setShowTutorial(tutorialRequested);
|
||||
}
|
||||
const moduleContext = {
|
||||
getModuleData,
|
||||
storageReady,
|
||||
|
|
@ -222,15 +227,6 @@ function ToolboxView({ siteContent, toolbox, toolboxGame, embedded, actions, sto
|
|||
refresh: () => {}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (currentToolboxIdRef.current === toolboxId) {
|
||||
if (shouldShowTutorial(toolbox, pendingTutorialToolboxId)) setShowTutorial(true);
|
||||
return;
|
||||
}
|
||||
currentToolboxIdRef.current = toolboxId;
|
||||
setShowTutorial(shouldShowTutorial(toolbox, pendingTutorialToolboxId));
|
||||
}, [pendingTutorialToolboxId, toolbox, toolboxId, toolboxTutorial]);
|
||||
|
||||
function addModule(type, initialData = null) {
|
||||
if (!type) return;
|
||||
const module = { id: uid("mod"), type };
|
||||
|
|
@ -285,6 +281,7 @@ function ToolboxView({ siteContent, toolbox, toolboxGame, embedded, actions, sto
|
|||
</section>
|
||||
{!embedded && showTutorial && (
|
||||
<GuidedTooltipTour
|
||||
key={toolboxId}
|
||||
steps={siteContent.toolboxes.tutorial?.items || []}
|
||||
labels={{
|
||||
dismiss: siteContent.toolboxes.tutorial?.dismissLabel,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue