1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

ReactNativeClient: A better NAV_BACK logic to change folder or tag. (#984)

This commit is contained in:
Joybin Chen 2018-11-20 06:43:21 +08:00 committed by Laurent Cozic
parent efd7cc6a0c
commit fc8f53fd0e

View File

@ -222,12 +222,15 @@ const appReducer = (state = appDefaultState, action) => {
}
}
if (action.routeName == 'Welcome') navHistory = [];
//reg.logger().info('Route: ' + currentRouteName + ' => ' + action.routeName);
newState = Object.assign({}, state);
if (action.routeName == 'Welcome') {
navHistory = [];
newState.showSideMenu = true;
}
if ('noteId' in action) {
newState.selectedNoteIds = action.noteId ? [action.noteId] : [];
}
@ -598,12 +601,20 @@ class AppComponent extends React.Component {
if (this.props.showSideMenu) {
this.props.dispatch({ type: 'SIDE_MENU_CLOSE' });
return true;
if (this.props.historyCanGoBack) {
return true;
} else {
BackHandler.exitApp();
return false;
}
}
if (this.props.historyCanGoBack) {
this.props.dispatch({ type: 'NAV_BACK' });
return true;
} else if (!this.props.showSideMenu) {
this.props.dispatch({ type: 'SIDE_MENU_OPEN' });
return true;
}
BackHandler.exitApp();