Skip to content

Commit

Permalink
fix: useAppCheck hook
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi committed Dec 1, 2023
1 parent 653ee75 commit 39d7f0a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/screens/get-started-screen/use-device-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ rnfbProvider.configure({
appCheck().initializeAppCheck({ provider: rnfbProvider, isTokenAutoRefreshEnabled: true })

let isFetchingToken = false
let promisesToResolveOnToken: ((value: string | undefined) => void)[] = []
const promisesToResolveOnToken: ((value: string | undefined) => void)[] = []

export const getAppCheckToken = async (): Promise<string | undefined> => {
// If we're already fetching the token, wait for it to be fetched
Expand All @@ -43,7 +43,10 @@ export const getAppCheckToken = async (): Promise<string | undefined> => {
resolve && resolve(token)
}

isFetchingToken = false
if (isFetchingToken) {
isFetchingToken = false
}

return token
}

Expand All @@ -58,7 +61,7 @@ const useAppCheckToken = ({ skip = false }: { skip?: boolean }): string | undefi
})()
}, [skip])

return undefined
return token
}

export default useAppCheckToken

0 comments on commit 39d7f0a

Please sign in to comment.