Skip to content

Commit

Permalink
disable clipboard check in foreground on ios (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
KKA11010 authored Sep 13, 2023
1 parent 07116bc commit dc7ff0f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ function _App() {
appState.current.match(/inactive|background/) &&
nextAppState === 'active'
) {
l('App has come to the foreground!')
l('[PIN] App has come to the foreground!')
// check for pin attempts and app locked state
await handlePinForeground()
} else {
l('App has gone to the background!')
l('[PIN] App has gone to the background!')
// store timestamp to activate auth after > 5mins in background
await store.set(STORE_KEYS.bgCounter, `${Math.ceil(Date.now() / 1000)}`)
}
Expand Down
8 changes: 6 additions & 2 deletions src/context/FocusClaim.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getEncodedToken } from '@cashu/cashu-ts'
import { isIOS } from '@consts'
import { getMintsUrls } from '@db'
import { l } from '@log'
import type { ITokenInfo } from '@model'
Expand Down Expand Up @@ -105,24 +106,27 @@ const useFocusClaim = () => {
}

useEffect(() => {
// disable foreground claim on iOS
if (isIOS) { return }
// eslint-disable-next-line @typescript-eslint/no-misused-promises
const subscription = AppState.addEventListener('change', async nextAppState => {
if (
appState.current.match(/inactive|background/) &&
nextAppState === 'active'
) {
l('App has come to the foreground!')
l('[Claim token] App has come to the foreground!')
setClaimed(false)
// check for clipboard valid cashu token when the app comes to the foregorund
await handleForeground()
} else {
l('App has gone to the background!')
l('[Claim token] App has gone to the background!')
}
appState.current = nextAppState
})
return () => subscription.remove()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

return {
claimed,
setClaimed,
Expand Down

0 comments on commit dc7ff0f

Please sign in to comment.