[FIX] Android crashing when restoring from background (#2238)
This commit is contained in:
parent
68e9e1455b
commit
a7e7d1fdcb
|
@ -13,7 +13,8 @@ public class MainActivity extends ReactFragmentActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
// https://github.com/software-mansion/react-native-screens/issues/17#issuecomment-424704067
|
||||||
|
super.onCreate(null);
|
||||||
RNBootSplash.init(R.drawable.launch_screen, MainActivity.this);
|
RNBootSplash.init(R.drawable.launch_screen, MainActivity.this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,22 @@ class RoomsListView extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
const {
|
||||||
|
navigation, closeServerDropdown, appState
|
||||||
|
} = this.props;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* - When didMount is triggered and appState is foreground,
|
||||||
|
* it means the user is logging in and selectServer has ran, so we can getSubscriptions
|
||||||
|
*
|
||||||
|
* - When didMount is triggered and appState is background,
|
||||||
|
* it means the user has resumed the app, so selectServer needs to be triggered,
|
||||||
|
* which is going to change server and getSubscriptions will be triggered by componentWillReceiveProps
|
||||||
|
*/
|
||||||
|
if (appState === 'foreground') {
|
||||||
this.getSubscriptions();
|
this.getSubscriptions();
|
||||||
const { navigation, closeServerDropdown } = this.props;
|
}
|
||||||
|
|
||||||
if (isTablet) {
|
if (isTablet) {
|
||||||
EventEmitter.addEventListener(KEY_COMMAND, this.handleCommands);
|
EventEmitter.addEventListener(KEY_COMMAND, this.handleCommands);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue