Wait until flags are loaded to show beta modal

This commit is contained in:
David Corbitt
2023-08-23 18:27:39 -07:00
parent af722128e8
commit 678392ef17
2 changed files with 5 additions and 1 deletions

View File

@@ -168,6 +168,7 @@ export default function AppShell({
}, [requireAuth, user, authLoading]);
const flags = useAppStore((s) => s.featureFlags.featureFlags);
const flagsLoaded = useAppStore((s) => s.featureFlags.flagsLoaded);
return (
<>
@@ -180,7 +181,7 @@ export default function AppShell({
{children}
</Box>
</Flex>
{requireBeta && !flags.betaAccess && <BetaModal />}
{requireBeta && flagsLoaded && !flags.betaAccess && <BetaModal />}
</>
);
}

View File

@@ -1,6 +1,7 @@
import { type SliceCreator } from "./store";
export type FeatureFlagsSlice = {
flagsLoaded: boolean;
featureFlags: {
betaAccess: boolean;
};
@@ -8,6 +9,7 @@ export type FeatureFlagsSlice = {
};
export const createFeatureFlagsSlice: SliceCreator<FeatureFlagsSlice> = (set) => ({
flagsLoaded: false,
featureFlags: {
betaAccess: false,
},
@@ -16,5 +18,6 @@ export const createFeatureFlagsSlice: SliceCreator<FeatureFlagsSlice> = (set) =>
state.featureFlags.featureFlags = {
betaAccess: flags?.includes("betaAccess") ?? false,
};
state.featureFlags.flagsLoaded = true;
}),
});