change to bool

This commit is contained in:
Hailey
2024-06-17 20:57:50 -07:00
parent a16d350aeb
commit ffdc3dca69
2 changed files with 11 additions and 11 deletions
+2 -2
View File
@@ -95,7 +95,7 @@ export const schema = z.object({
isClip: z.boolean().optional(),
})
.optional(),
usedStarterPacks: z.array(z.string()).optional(),
hasCheckedForStarterPack: z.boolean().optional(),
})
export type Schema = z.infer<typeof schema>
@@ -135,5 +135,5 @@ export const defaults: Schema = {
disableAutoplay: prefersReducedMotion,
kawaii: false,
currentStarterPack: undefined,
usedStarterPacks: [],
hasCheckedForStarterPack: false,
}
+9 -9
View File
@@ -2,25 +2,25 @@ import React from 'react'
import * as persisted from '#/state/persisted'
type StateContext = string[] | undefined
type SetContext = (v: string) => void
type StateContext = boolean | undefined
type SetContext = (v: boolean) => void
const stateContext = React.createContext<StateContext>([])
const setContext = React.createContext<SetContext>((_: string) => {})
const stateContext = React.createContext<StateContext>(false)
const setContext = React.createContext<SetContext>((_: boolean) => {})
export function Provider({children}: {children: React.ReactNode}) {
const [state, setState] = React.useState<StateContext>(() =>
persisted.get('usedStarterPacks'),
persisted.get('hasCheckedForStarterPack'),
)
const setStateWrapped = (v: string) => {
persisted.write('usedStarterPacks', [...(state ? state : []), v])
setState(prev => [...(prev ? prev : []), v])
const setStateWrapped = (v: boolean) => {
setState(v)
persisted.write('hasCheckedForStarterPack', v)
}
React.useEffect(() => {
return persisted.onUpdate(() => {
setState(persisted.get('usedStarterPacks'))
setState(persisted.get('hasCheckedForStarterPack'))
})
}, [])