all: Aggiunte varie feature e riscritte svariate cose

This commit is contained in:
2022-12-01 03:45:29 +01:00
parent bd055f484d
commit 8fdef2981d
22 changed files with 714 additions and 422 deletions
-20
View File
@@ -14,26 +14,6 @@ export const MetadataContext = createContext<Metadata>({})
export const ServerContext = createContext<boolean>(false)
export const ClientContext = createContext<boolean>(false)
type CurrentUserHook = (onLoaded?: (user: User | null) => void) => [User | null, () => Promise<void>]
export const useCurrentUser: CurrentUserHook = onLoaded => {
const [user, setUser] = useState(null)
const logout = async () => {
await server.post('/api/logout')
setUser(null)
}
useEffect(() => {
server.get('/api/current-user').then(user => {
setUser(user)
onLoaded?.(user)
})
}, [])
return [user, logout]
}
type RefreshFunction = () => AbortController
type HeuristicStateUpdater<S> = StateUpdater<S>