diff --git a/app/screens/entry/entry.js b/app/screens/entry/entry.js index 1a6fa9073..500023a61 100644 --- a/app/screens/entry/entry.js +++ b/app/screens/entry/entry.js @@ -75,11 +75,18 @@ export default class Entry extends PureComponent { launchLogin: false, launchChannel: false, }; + + this.unsubscribeFromStore = null; } componentDidMount() { Client4.setUserAgent(DeviceInfo.getUserAgent()); - this.unsubscribeFromStore = store.subscribe(this.listenForHydration); + + if (store.getState().views.root.hydrationComplete) { + this.handleHydrationComplete(); + } else { + this.unsubscribeFromStore = store.subscribe(this.listenForHydration); + } EventEmitter.on(ViewTypes.LAUNCH_LOGIN, this.handleLaunchLogin); EventEmitter.on(ViewTypes.LAUNCH_CHANNEL, this.handleLaunchChannel); @@ -107,13 +114,6 @@ export default class Entry extends PureComponent { }; listenForHydration = () => { - const { - actions: { - autoUpdateTimezone, - }, - enableTimezone, - deviceTimezone, - } = this.props; const {getState} = store; const state = getState(); @@ -122,26 +122,43 @@ export default class Entry extends PureComponent { } if (state.views.root.hydrationComplete) { + this.handleHydrationComplete(); + } + }; + + handleHydrationComplete = () => { + if (this.unsubscribeFromStore) { this.unsubscribeFromStore(); + this.unsubscribeFromStore = null; + } - if (enableTimezone) { - autoUpdateTimezone(deviceTimezone); - } - - this.setAppCredentials(); - this.setStartupThemes(); - this.handleNotification(); - this.loadSystemEmojis(); - - if (Platform.OS === 'android') { - this.launchForAndroid(); - return; - } + this.autoUpdateTimezone(); + this.setAppCredentials(); + this.setStartupThemes(); + this.handleNotification(); + this.loadSystemEmojis(); + if (Platform.OS === 'android') { + this.launchForAndroid(); + } else { this.launchForiOS(); } }; + autoUpdateTimezone = () => { + const { + actions: { + autoUpdateTimezone, + }, + enableTimezone, + deviceTimezone, + } = this.props; + + if (enableTimezone) { + autoUpdateTimezone(deviceTimezone); + } + }; + configurePushNotifications = () => { const configureNotifications = lazyLoadPushNotifications(); configureNotifications();