04fda0f142
* handle android back button in composer * improve backHandler error handling * simplify composer onClose functionality
20 lines
505 B
TypeScript
20 lines
505 B
TypeScript
import {isAndroid} from 'platform/detection'
|
|
import {BackHandler} from 'react-native'
|
|
import {RootStoreModel} from 'state/index'
|
|
|
|
export function init(store: RootStoreModel) {
|
|
// only register back handler on android, otherwise it throws an error
|
|
if (isAndroid) {
|
|
const backHandler = BackHandler.addEventListener(
|
|
'hardwareBackPress',
|
|
() => {
|
|
return store.shell.closeAnyActiveElement()
|
|
},
|
|
)
|
|
return () => {
|
|
backHandler.remove()
|
|
}
|
|
}
|
|
return () => {}
|
|
}
|