launch: get tutorial state from zustand

The check for rendering the tutorial modal
was relying on a passed prop that does not exist now.
This commit is contained in:
Matilde Park 2021-03-26 15:53:47 -04:00
parent 5c3bce8dbe
commit 4e6655db3b

View File

@ -49,7 +49,18 @@ export default function LaunchApp(props) {
const baseHash = useLaunchState(state => state.baseHash); const baseHash = useLaunchState(state => state.baseHash);
const [hashText, setHashText] = useState(baseHash); const [hashText, setHashText] = useState(baseHash);
const [exitingTut, setExitingTut] = useState(false); const [exitingTut, setExitingTut] = useState(false);
const seen = useSettingsState(s => s?.tutorial?.seen) ?? true;
const associations = useMetadataState(s => s.associations); const associations = useMetadataState(s => s.associations);
const contacts = useContactState(state => state.contacts);
const hasLoaded = useMemo(() => Object.keys(contacts).length > 0, [contacts]);
const notificationsCount = useHarkState(state => state.notificationsCount);
const calmState = useSettingsState(selectCalmState);
const { hideUtilities } = calmState;
const { tutorialProgress, nextTutStep } = useLocalState(tutSelector);
let { hideGroups } = useLocalState(tutSelector);
!hideGroups ? { hideGroups } = calmState : null;
const waiter = useWaitForProps({ ...props, associations });
const hashBox = ( const hashBox = (
<Box <Box
position={["relative", "absolute"]} position={["relative", "absolute"]}
@ -88,14 +99,6 @@ export default function LaunchApp(props) {
} }
}, [query]); }, [query]);
const calmState = useSettingsState(selectCalmState);
const { hideUtilities } = calmState;
const { tutorialProgress, nextTutStep } = useLocalState(tutSelector);
let { hideGroups } = useLocalState(tutSelector);
!hideGroups ? { hideGroups } = calmState : null;
const waiter = useWaitForProps({ ...props, associations });
const { modal, showModal } = useModal({ const { modal, showModal } = useModal({
position: 'relative', position: 'relative',
maxWidth: '350px', maxWidth: '350px',
@ -158,17 +161,12 @@ export default function LaunchApp(props) {
</Col> </Col>
)} )}
}); });
const contacts = useContactState(state => state.contacts);
const hasLoaded = useMemo(() => Object.keys(contacts).length > 0, [contacts]);
const notificationsCount = useHarkState(state => state.notificationsCount);
useEffect(() => { useEffect(() => {
const seenTutorial = _.get(props.settings, ['tutorial', 'seen'], true); if(hasLoaded && !seen && tutorialProgress === 'hidden') {
if(hasLoaded && !seenTutorial && tutorialProgress === 'hidden') {
showModal(); showModal();
} }
}, [props.settings, hasLoaded]); }, [seen, hasLoaded]);
return ( return (
<> <>