feat: auto-activate biometrics prompt when mobile regains focus (#1891)

This commit is contained in:
Aman Harwara
2022-10-27 02:02:33 +05:30
committed by GitHub
parent d817a2115e
commit 3bd1ad38ad
5 changed files with 72 additions and 10 deletions

View File

@@ -1,6 +1,10 @@
import { ReactNativeToWebEvent, WebApplicationInterface } from '@standardnotes/snjs'
export type NativeMobileEventListener = (event: ReactNativeToWebEvent) => void
export class MobileWebReceiver {
private listeners: Set<NativeMobileEventListener> = new Set()
constructor(private application: WebApplicationInterface) {
this.listenForNativeMobileEvents()
}
@@ -39,6 +43,14 @@ export class MobileWebReceiver {
}
}
addReactListener = (listener: NativeMobileEventListener) => {
this.listeners.add(listener)
return () => {
this.listeners.delete(listener)
}
}
handleNativeEvent(event: ReactNativeToWebEvent) {
switch (event) {
case ReactNativeToWebEvent.EnteringBackground:
@@ -60,5 +72,7 @@ export class MobileWebReceiver {
default:
break
}
this.listeners.forEach((listener) => listener(event))
}
}