mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-26 20:06:28 -08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5d7ee4303 | ||
|
|
86c38c1052 |
@@ -1,4 +1,12 @@
|
|||||||
import { createContext, Reducer, useContext, useLayoutEffect, useReducer } from 'react';
|
import {
|
||||||
|
createContext,
|
||||||
|
Reducer,
|
||||||
|
useContext,
|
||||||
|
useEffect,
|
||||||
|
useLayoutEffect,
|
||||||
|
useReducer,
|
||||||
|
useState,
|
||||||
|
} from 'react';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { useConfig } from './config';
|
import { useConfig } from './config';
|
||||||
|
|
||||||
@@ -52,7 +60,8 @@ export function useProvideOnboarding(): OnboardingContext {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const { state: locatioState } = useLocation();
|
const { state: locatioState, pathname } = useLocation();
|
||||||
|
const [previousPath, setPreviousPath] = useState(pathname);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
const { alonePage = false }: { alonePage?: boolean } = (locatioState as any) || {};
|
const { alonePage = false }: { alonePage?: boolean } = (locatioState as any) || {};
|
||||||
@@ -61,6 +70,18 @@ export function useProvideOnboarding(): OnboardingContext {
|
|||||||
dispatch({ type: 'alone-page', value: alonePage });
|
dispatch({ type: 'alone-page', value: alonePage });
|
||||||
}, [locatioState, state]);
|
}, [locatioState, state]);
|
||||||
|
|
||||||
|
const onboardingEnded = () => {
|
||||||
|
setConfig({ doneOnboarding: true });
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPreviousPath(pathname);
|
||||||
|
|
||||||
|
if (!pathname.startsWith('/onboarding') && previousPath.startsWith('/onboarding')) {
|
||||||
|
onboardingEnded();
|
||||||
|
}
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
state,
|
state,
|
||||||
applyProgress: (value: number) => {
|
applyProgress: (value: number) => {
|
||||||
|
|||||||
Reference in new issue
Block a user