aboutsummaryrefslogtreecommitdiffstats
path: root/apps/mobile/lib/session.ts
blob: bafb3a09b9da1f92f20b68f13fd7ed471a38534d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { useCallback } from "react";

import useAppSettings from "./settings";

export function useSession() {
  const { settings, setSettings } = useAppSettings();

  const logout = useCallback(() => {
    setSettings({ ...settings, apiKey: undefined });
  }, [settings, setSettings]);

  return {
    logout,
  };
}

export function useIsLoggedIn() {
  const { settings, isLoading } = useAppSettings();

  return isLoading ? undefined : !!settings.apiKey;
}