Skip to content

Commit

Permalink
chore: fix app start?
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasburtey committed Feb 4, 2023
1 parent 476af2a commit 71bdd8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions app/hooks/use-logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import useToken from "./use-token"
import crashlytics from "@react-native-firebase/crashlytics"
import { logLogout } from "@app/utils/analytics"
import { useCallback } from "react"
import { useApolloClient } from "@apollo/client"

const useLogout = () => {
const client = useApolloClient()
// ideally, we would want to reset the apollo client as well here
// but it would create a circular dependancy in the apollo client wrapper
// because it clears the token, and this is a depenercy of the apollo client wrapper
// or, when shouldClearToken = false, the GaloyInstance is been updated, and this is
// also a dependancy in the apollo client wrapper, apollo client will be recreated in every cases
const { clearToken } = useToken()

const logout = useCallback(
async (shouldClearToken = true): Promise<void> => {
try {
await Promise.all([
client.clearStore(),
AsyncStorage.multiRemove([BUILD_VERSION]),
KeyStoreWrapper.removeIsBiometricsEnabled(),
KeyStoreWrapper.removePin(),
Expand All @@ -34,7 +36,7 @@ const useLogout = () => {
}
}
},
[clearToken, client],
[clearToken],
)

return {
Expand Down
1 change: 0 additions & 1 deletion app/screens/debug-screen/debug-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const DebugScreen: React.FC = () => {

const handleSave = () => {
logout(false)

saveToken(newToken || "")

if (newGaloyInstance === "Custom") {
Expand Down

0 comments on commit 71bdd8c

Please sign in to comment.