Implement reset to block navigating back from home

parent f39cb66f
......@@ -15,7 +15,7 @@ import {
// NativeEventEmitter,
} from 'react-native';
import { SecureStore, LocalAuthentication, Linking } from 'expo';
import { NavigationActions } from 'react-navigation';
import { NavigationActions, StackActions } from 'react-navigation';
import { nap } from '../helper';
import store from '../store';
import AppStorage from './app-storage';
......@@ -47,7 +47,7 @@ export const grpc = sinon.createStubInstance(GrpcAction); // STUB DURING DEVELOP
// export const ipc = new IpcAction(grpc);
export const ipc = sinon.createStubInstance(IpcAction); // STUB DURING DEVELOPMENT
export const log = new LogAction(store, ipc, false);
export const nav = new NavAction(store, NavigationActions);
export const nav = new NavAction(store, NavigationActions, StackActions);
export const notify = new NotificationAction(store, nav);
export const wallet = new WalletAction(store, grpc, db, nav, notify);
export const info = new InfoAction(store, grpc, nav, notify);
......
......@@ -5,14 +5,22 @@
*/
class NavAction {
constructor(store, Navigation) {
constructor(store, NavigationActions, StackActions) {
this._store = store;
this._Navigation = Navigation;
this._navActions = NavigationActions;
this._stackActions = StackActions;
}
setTopLevelNavigator(navigatorRef) {
this._navigate = (routeName, params) =>
navigatorRef.dispatch(this._Navigation.navigate({ routeName, params }));
navigatorRef.dispatch(this._navActions.navigate({ routeName, params }));
this._reset = (routeName, params) =>
navigatorRef.dispatch(
this._stackActions.reset({
index: 0,
actions: [this._navActions.navigate({ routeName, params })],
})
);
this._store.navReady = true;
}
......@@ -78,6 +86,7 @@ class NavAction {
goHome() {
this._navigate('Home');
this._reset('Home');
}
goPay() {
......
......@@ -193,7 +193,6 @@ const MainStack = createStackNavigator(
NewAddress,
Password,
LoaderSyncing,
Home,
Settings,
SettingsUnit,
SettingsFiat,
......@@ -245,6 +244,7 @@ const ChannelStack = createStackNavigator(
const RootStack = createStackNavigator(
{
Home,
Main: MainStack,
Invoice: InvoiceStack,
Pay: PayStack,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment