Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/browser/components/splashScreens/SplashScreenProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import React, { useState, useCallback, useEffect, type ReactNode } from "react";
import React, {
createContext,
useContext,
useState,
useCallback,
useEffect,
type ReactNode,
} from "react";
import { SPLASH_REGISTRY, DISABLE_SPLASH_SCREENS, type SplashConfig } from "./index";
import { useAPI } from "@/browser/contexts/API";

const SplashScreenActiveContext = createContext(false);

export function useIsSplashScreenActive(): boolean {
return useContext(SplashScreenActiveContext);
}

export function SplashScreenProvider({ children }: { children: ReactNode }) {
const { api } = useAPI();
const [queue, setQueue] = useState<SplashConfig[]>([]);
Expand Down Expand Up @@ -55,15 +68,12 @@ export function SplashScreenProvider({ children }: { children: ReactNode }) {
setQueue((q) => q.slice(1));
}, [currentSplash, api]);

// Don't render splash until we've loaded the viewed state
if (!loaded) {
return <>{children}</>;
}
const isSplashScreenActive = loaded && currentSplash !== null;

return (
<>
<SplashScreenActiveContext.Provider value={isSplashScreenActive}>
{children}
{currentSplash && <currentSplash.component onDismiss={() => void dismiss()} />}
</>
{loaded && currentSplash && <currentSplash.component onDismiss={() => void dismiss()} />}
</SplashScreenActiveContext.Provider>
);
}
4 changes: 3 additions & 1 deletion src/browser/contexts/TutorialContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
type TutorialState,
type TutorialSequence,
} from "@/common/constants/storage";
import { useIsSplashScreenActive } from "@/browser/components/splashScreens/SplashScreenProvider";
import { readPersistedState, updatePersistedState } from "@/browser/hooks/usePersistedState";

// Tutorial step definitions for each sequence
Expand Down Expand Up @@ -73,6 +74,7 @@ export function TutorialProvider({ children }: TutorialProviderProps) {
const [tutorialState, setTutorialState] = useState<TutorialState>(() =>
readPersistedState(TUTORIAL_STATE_KEY, DEFAULT_TUTORIAL_STATE)
);
const isSplashScreenActive = useIsSplashScreenActive();
const [activeSequence, setActiveSequence] = useState<TutorialSequence | null>(null);
const [currentStepIndex, setCurrentStepIndex] = useState(0);

Expand Down Expand Up @@ -158,7 +160,7 @@ export function TutorialProvider({ children }: TutorialProviderProps) {
return (
<TutorialContext.Provider value={contextValue}>
{children}
{currentStep && activeSteps && (
{!isSplashScreenActive && currentStep && activeSteps && (
<TutorialTooltip
step={currentStep}
currentStep={currentStepIndex + 1}
Expand Down
Loading