handle used URLs nicely

This commit is contained in:
Hailey
2024-06-17 00:21:39 -07:00
parent 02f4477067
commit c7ddaa1c4d
5 changed files with 38 additions and 4 deletions
+3 -1
View File
@@ -16,7 +16,9 @@ const stateContext = React.createContext<StateContext>(undefined)
const setContext = React.createContext<SetContext>((_: StateContext) => {})
export function Provider({children}: {children: React.ReactNode}) {
const [state, setState] = React.useState<StateContext>()
const [state, setState] = React.useState<StateContext>(() =>
persisted.get('currentStarterPack'),
)
const setStateWrapped = (v: StateContext) => {
setState(v)
+4 -1
View File
@@ -9,9 +9,12 @@ const stateContext = React.createContext<StateContext>([])
const setContext = React.createContext<SetContext>((_: string) => {})
export function Provider({children}: {children: React.ReactNode}) {
const [state, setState] = React.useState<StateContext>([])
const [state, setState] = React.useState<StateContext>(() =>
persisted.get('usedStarterPacks'),
)
const setStateWrapped = (v: string) => {
console.log('ADDING!!!', v)
persisted.write('usedStarterPacks', [...(state ? state : []), v])
setState(prev => [...(prev ? prev : []), v])
}