bsky-app/src/lib/routes/back-handler.ts
Paul Frazee d35f7c1f1a
Android fixes (#515)
* Fix profile screen performance on android and remove dead code

* Correctly handle android hardware back btn

* Fix EditProfile modal for android

* Fix lint
2023-04-22 17:14:20 -05:00

11 lines
358 B
TypeScript

import {BackHandler} from 'react-native'
import {RootStoreModel} from 'state/index'
export function onBack(cb: () => boolean): () => void {
const subscription = BackHandler.addEventListener('hardwareBackPress', cb)
return () => subscription.remove()
}
export function init(store: RootStoreModel) {
onBack(() => store.shell.closeAnyActiveElement())
}