Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable clipboard check in foreground on ios #209

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading