mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-21 17:41: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 { 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(() => {
|
||||
const { alonePage = false }: { alonePage?: boolean } = (locatioState as any) || {};
|
||||
@@ -61,6 +70,18 @@ export function useProvideOnboarding(): OnboardingContext {
|
||||
dispatch({ type: 'alone-page', value: alonePage });
|
||||
}, [locatioState, state]);
|
||||
|
||||
const onboardingEnded = () => {
|
||||
setConfig({ doneOnboarding: true });
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
setPreviousPath(pathname);
|
||||
|
||||
if (!pathname.startsWith('/onboarding') && previousPath.startsWith('/onboarding')) {
|
||||
onboardingEnded();
|
||||
}
|
||||
}, [pathname]);
|
||||
|
||||
return {
|
||||
state,
|
||||
applyProgress: (value: number) => {
|
||||
|
||||
Reference in new issue
Block a user