fix: 🩹 Fix persistent store
Tim Izzo tim@octree.ch
Thu, 29 Sep 2022 13:48:46 +0200
3 files changed,
16 insertions(+),
16 deletions(-)
M
frontend/stores/useOnboardingStore.ts
→
frontend/stores/useOnboardingStore.ts
@@ -9,7 +9,7 @@ type State = OnBoarding & {
setOnboarding: (onboarding: Partial<OnBoarding>) => void; }; -const useOnboardingStore = create<State>( +const useOnboardingStore = create<State>()( persist( set => ({ onboardingUser: false,
M
frontend/stores/useRedirectUrl.ts
→
frontend/stores/useRedirectUrl.ts
@@ -7,16 +7,21 @@ setRedirectUrl: (redirectUrl: string) => void;
getRedirectUrl: () => string; }; -const useRedirectUrlStore = create<State>( - persist((set, get) => ({ - redirectUrl: null, - setRedirectUrl: redirectUrl => set({redirectUrl}), - getRedirectUrl: () => { - const redirectUrl = get().redirectUrl; - set({redirectUrl: null}); - return redirectUrl; - }, - })) +const useRedirectUrlStore = create<State>()( + persist( + (set, get) => ({ + redirectUrl: null, + setRedirectUrl: redirectUrl => set({redirectUrl}), + getRedirectUrl: () => { + const redirectUrl = get().redirectUrl; + set({redirectUrl: null}); + return redirectUrl; + }, + }), + { + name: 'REDIRECT_URL_STORE', + } + ) ); export default useRedirectUrlStore;
M
frontend/stores/useTourStore.ts
→
frontend/stores/useTourStore.ts
@@ -12,11 +12,6 @@ type State = Tour & {
setTour: (tour: Partial<Tour>) => void; }; -const ONBOARDING_STORAGE_KEY = 'showWelcome'; -let persistedShowWelcome = null; -if(typeof localStorage !== 'undefined') - persistedShowWelcome = JSON.parse(localStorage.getItem(ONBOARDING_STORAGE_KEY)); - const useTourStore = create<State>(set => ({ showWelcome: false, isCreator: null,