From d11b7dcdb304b383a877f8f737de78cdacfa17de Mon Sep 17 00:00:00 2001 From: Mashy Date: Fri, 17 Jan 2020 17:20:22 +1000 Subject: [PATCH] tutorial client fixes --- client/src/components/vbox.info.jsx | 7 ++++--- client/src/events.jsx | 2 +- client/src/reducers.jsx | 2 +- client/src/tutorial.utils.jsx | 10 ++++++++-- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/client/src/components/vbox.info.jsx b/client/src/components/vbox.info.jsx index d2eddbec..126780be 100644 --- a/client/src/components/vbox.info.jsx +++ b/client/src/components/vbox.info.jsx @@ -5,8 +5,8 @@ const { tutorialStage } = require('../tutorial.utils'); const { genItemInfo } = require('./vbox.utils'); const addState = connect( - ({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview }) => ({ - info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, + ({ info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated }) => ({ + info, player, tutorial, vboxInfo, itemInfo, instance, comboPreview, authenticated })); @@ -35,12 +35,13 @@ class Info extends preact.Component { itemInfo, instance, comboPreview, + authenticated, } = props; // dispaly priority // tutorial -> comboPreview -> vboxInfo -> info if (tutorial) { - const tutorialStageInfo = tutorialStage(tutorial, clearTutorial, instance); + const tutorialStageInfo = tutorialStage(authenticated, tutorial, clearTutorial, instance); if (tutorialStageInfo) return tutorialStageInfo; } if (comboPreview) return genItemInfo(comboPreview, itemInfo, player); diff --git a/client/src/events.jsx b/client/src/events.jsx index 83c9982d..1354a363 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -185,7 +185,7 @@ function registerEvents(store) { const player = v.players.find(p => p.id === account.id); store.dispatch(actions.setPlayer(player)); - if (tutorial) tutorialVbox(player, store, tutorial); + if (tutorial && process.env.NODE_ENV !== 'development') tutorialVbox(player, store, tutorial); if (v.phase === 'Finished') { ws.sendAccountInstances(); diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index 3c5faf4a..6330f0eb 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -53,7 +53,7 @@ module.exports = { teamPage: createReducer(0, 'SET_TEAM_PAGE'), teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'), - tutorial: createReducer(localStorage.getItem('tutorial-complete') ? null : 1, 'SET_TUTORIAL'), + tutorial: createReducer(1, 'SET_TUTORIAL'), vboxSelected: createReducer({ storeSelect: [], stashSelect: [] }, 'SET_VBOX_SELECTED'), vboxCombiner: createReducer(null, 'SET_VBOX_COMBINER'), diff --git a/client/src/tutorial.utils.jsx b/client/src/tutorial.utils.jsx index 2aebae73..216ea0d2 100644 --- a/client/src/tutorial.utils.jsx +++ b/client/src/tutorial.utils.jsx @@ -106,7 +106,7 @@ function tutorialVbox(player, store, tutorial) { store.dispatch(actions.setTutorial(stage)); } -function tutorialStage(tutorial, clearTutorial, instance) { +function tutorialStage(authenticated, tutorial, clearTutorial, instance) { if (!(instance.time_control === 'Practice' && instance.rounds.length === 1)) return false; const exit = () => clearTutorial(); @@ -197,7 +197,6 @@ function tutorialStage(tutorial, clearTutorial, instance) { } if (tutorial === 8) { - localStorage.setItem('tutorial-complete', true); if (window.innerWidth < 1000) { return exit(); } @@ -221,11 +220,18 @@ function tutorialStage(tutorial, clearTutorial, instance) { onMouseDown={exit}> Continue : null; + const skipTutorial = authenticated && !exitTutorial ? + + : null; + return (
{tutorialText()}
{exitTutorial} + {skipTutorial}
); }