diff --git a/android/app/src/main/java/chat/rocket/reactnative/MainActivity.java b/android/app/src/main/java/chat/rocket/reactnative/MainActivity.java index de66369a..75922913 100644 --- a/android/app/src/main/java/chat/rocket/reactnative/MainActivity.java +++ b/android/app/src/main/java/chat/rocket/reactnative/MainActivity.java @@ -13,7 +13,8 @@ public class MainActivity extends ReactFragmentActivity { @Override 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); } diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index f97e67c3..39b035e6 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -151,8 +151,22 @@ class RoomsListView extends React.Component { } componentDidMount() { - this.getSubscriptions(); - const { navigation, closeServerDropdown } = this.props; + 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(); + } + if (isTablet) { EventEmitter.addEventListener(KEY_COMMAND, this.handleCommands); }