mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-19 19:31:54 +03:00
Fixed push navigation issue
This commit is contained in:
parent
b1947e7e6f
commit
9bda8f39e9
@ -2,16 +2,26 @@ import { NavigationActions } from 'react-navigation';
|
||||
|
||||
let _navigator;
|
||||
|
||||
let navigationStack = [];
|
||||
|
||||
const setTopLevelNavigator = navigatorRef => {
|
||||
_navigator = navigatorRef;
|
||||
if (navigationStack.length > 0) {
|
||||
navigationStack.forEach(item => navigate(item));
|
||||
navigationStack = [];
|
||||
}
|
||||
};
|
||||
|
||||
const navigate = navigationProps => {
|
||||
_navigator.dispatch(
|
||||
NavigationActions.navigate({
|
||||
...navigationProps,
|
||||
}),
|
||||
);
|
||||
if (!_navigator) {
|
||||
navigationStack.push(navigationProps);
|
||||
} else {
|
||||
_navigator.dispatch(
|
||||
NavigationActions.navigate({
|
||||
...navigationProps,
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
// add other navigation functions that you need and export them
|
||||
|
@ -110,8 +110,6 @@ class ApplicationContainer extends Component {
|
||||
AppState.addEventListener('change', this._handleAppStateChange);
|
||||
setPreviousAppState();
|
||||
|
||||
this._createPushListener();
|
||||
|
||||
if (nativeThemeEventEmitter) {
|
||||
nativeThemeEventEmitter.on('currentModeChanged', newMode => {
|
||||
const { dispatch } = this.props;
|
||||
@ -119,6 +117,7 @@ class ApplicationContainer extends Component {
|
||||
dispatch(isDarkTheme(newMode === 'dark'));
|
||||
});
|
||||
}
|
||||
this._createPushListener();
|
||||
};
|
||||
|
||||
componentWillUnmount() {
|
||||
@ -235,8 +234,8 @@ class ApplicationContainer extends Component {
|
||||
};
|
||||
|
||||
_fetchApp = async () => {
|
||||
await this._refreshGlobalProps();
|
||||
await this._getSettings();
|
||||
await this._refreshGlobalProps();
|
||||
const userRealmObject = await this._getUserDataFromRealm();
|
||||
this.setState({ isReady: true });
|
||||
|
||||
@ -463,6 +462,7 @@ class ApplicationContainer extends Component {
|
||||
|
||||
if (settings) {
|
||||
dispatch(isDarkTheme(nativeThemeInitialMode === 'dark' || settings.isDarkTheme));
|
||||
this.setState({ isThemeReady: true });
|
||||
if (settings.isPinCodeOpen !== '') dispatch(isPinCodeOpen(settings.isPinCodeOpen));
|
||||
if (settings.language !== '') dispatch(setLanguage(settings.language));
|
||||
if (settings.server !== '') dispatch(setApi(settings.server));
|
||||
@ -483,8 +483,6 @@ class ApplicationContainer extends Component {
|
||||
if (settings.currency !== '') {
|
||||
dispatch(setCurrency(settings.currency !== '' ? settings.currency : 'usd'));
|
||||
}
|
||||
|
||||
this.setState({ isThemeReady: true });
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,13 +40,15 @@ const Application = () => {
|
||||
>
|
||||
<PinCode />
|
||||
</Modal>
|
||||
<ApplicationScreen
|
||||
isConnected={isConnected}
|
||||
locale={locale}
|
||||
toastNotification={toastNotification}
|
||||
isReady={isReady}
|
||||
isDarkTheme={isDarkTheme}
|
||||
/>
|
||||
{isThemeReady && isRenderRequire && (
|
||||
<ApplicationScreen
|
||||
isConnected={isConnected}
|
||||
locale={locale}
|
||||
toastNotification={toastNotification}
|
||||
isReady={isReady}
|
||||
isDarkTheme={isDarkTheme}
|
||||
/>
|
||||
)}
|
||||
{(showAnimation || !isReady || !isRenderRequire || !isThemeReady) && <Launch />}
|
||||
</Fragment>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user