Skip to content
This repository was archived by the owner on Feb 23, 2021. It is now read-only.

Commit 2231715

Browse files
committed
Implement reset to block navigating back from home
1 parent f39cb66 commit 2231715

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/action/index-mobile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
// NativeEventEmitter,
1616
} from 'react-native';
1717
import { SecureStore, LocalAuthentication, Linking } from 'expo';
18-
import { NavigationActions } from 'react-navigation';
18+
import { NavigationActions, StackActions } from 'react-navigation';
1919
import { nap } from '../helper';
2020
import store from '../store';
2121
import AppStorage from './app-storage';
@@ -47,7 +47,7 @@ export const grpc = sinon.createStubInstance(GrpcAction); // STUB DURING DEVELOP
4747
// export const ipc = new IpcAction(grpc);
4848
export const ipc = sinon.createStubInstance(IpcAction); // STUB DURING DEVELOPMENT
4949
export const log = new LogAction(store, ipc, false);
50-
export const nav = new NavAction(store, NavigationActions);
50+
export const nav = new NavAction(store, NavigationActions, StackActions);
5151
export const notify = new NotificationAction(store, nav);
5252
export const wallet = new WalletAction(store, grpc, db, nav, notify);
5353
export const info = new InfoAction(store, grpc, nav, notify);

src/action/nav-mobile.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,22 @@
55
*/
66

77
class NavAction {
8-
constructor(store, Navigation) {
8+
constructor(store, NavigationActions, StackActions) {
99
this._store = store;
10-
this._Navigation = Navigation;
10+
this._navActions = NavigationActions;
11+
this._stackActions = StackActions;
1112
}
1213

1314
setTopLevelNavigator(navigatorRef) {
1415
this._navigate = (routeName, params) =>
15-
navigatorRef.dispatch(this._Navigation.navigate({ routeName, params }));
16+
navigatorRef.dispatch(this._navActions.navigate({ routeName, params }));
17+
this._reset = (routeName, params) =>
18+
navigatorRef.dispatch(
19+
this._stackActions.reset({
20+
index: 0,
21+
actions: [this._navActions.navigate({ routeName, params })],
22+
})
23+
);
1624
this._store.navReady = true;
1725
}
1826

@@ -78,6 +86,7 @@ class NavAction {
7886

7987
goHome() {
8088
this._navigate('Home');
89+
this._reset('Home');
8190
}
8291

8392
goPay() {

src/view/main-mobile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ const MainStack = createStackNavigator(
193193
NewAddress,
194194
Password,
195195
LoaderSyncing,
196-
Home,
197196
Settings,
198197
SettingsUnit,
199198
SettingsFiat,
@@ -245,6 +244,7 @@ const ChannelStack = createStackNavigator(
245244

246245
const RootStack = createStackNavigator(
247246
{
247+
Home,
248248
Main: MainStack,
249249
Invoice: InvoiceStack,
250250
Pay: PayStack,

0 commit comments

Comments
 (0)