Skip to content

Commit

Permalink
fix: start listening to backpress in lock view
Browse files Browse the repository at this point in the history
It seems nothing was listening to the backpress anymore.
Fixed that by starting listening to them directly in the view
as it feels safer than listening from a distant service layer
  • Loading branch information
acezard committed Dec 18, 2023
1 parent 6115334 commit adc1b88
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/view/Lock/useLockScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
validatePin
} from '/app/domain/authorization/services/LockScreenService'
import { useI18n } from '/locales/i18n'
import { SecurityNavigationService } from '/app/domain/authorization/services/SecurityNavigationService'

export const useLockScreenProps = (props: LockScreenProps): LockViewProps => {
const [biometryEnabled, setBiometryEnabled] = useState(false)
Expand All @@ -36,6 +37,16 @@ export const useLockScreenProps = (props: LockScreenProps): LockViewProps => {
const { fqdn } = getInstanceAndFqdnFromClient(client)
const { t } = useI18n()

// This is intended to ensure that the backpress listener is always active,
// and will always quit the app when the user is on the lock screen.
useEffect(() => {
SecurityNavigationService.startListening()

return () => {
SecurityNavigationService.stopListening()
}
})

const onUnlock = useCallback((): void => {
if (!props.route.params?.onSuccess) return reset(routes.home)

Expand Down

0 comments on commit adc1b88

Please sign in to comment.