Skip to content

Commit a163761

Browse files
committed
navReducer: Transplant away INITIAL_FETCH_COMPLETE logic.
Soon, we'll dismantle `navReducer`, as its purpose is incompatible with a design where we manage navigation state separately from our Redux-stored data (#3804). So, convert the `navReducer`'s `INITIAL_FETCH_COMPLETE` case into instructions to navigate to the main-tabs screen, if not already there, at the dispatch sites.
1 parent c9b5f51 commit a163761

File tree

3 files changed

+5
-33
lines changed

3 files changed

+5
-33
lines changed

src/message/fetchActions.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
} from '../types';
1111
import type { InitialData } from '../api/initialDataTypes';
1212
import * as api from '../api';
13-
import { resetToAccountPicker } from '../actions';
13+
import { resetToAccountPicker, resetToMainTabs } from '../actions';
1414
import { isClientError } from '../api/apiErrors';
1515
import {
1616
getAuth,
@@ -19,6 +19,7 @@ import {
1919
getLastMessageId,
2020
getCaughtUpForNarrow,
2121
getFetchingForNarrow,
22+
getCurrentRouteName,
2223
} from '../selectors';
2324
import config from '../config';
2425
import {
@@ -323,6 +324,9 @@ export const doInitialFetch = () => async (dispatch: Dispatch, getState: GetStat
323324
}
324325

325326
dispatch(realmInit(initData, new ZulipVersion(serverSettings.zulip_version)));
327+
if (getCurrentRouteName() !== 'main') {
328+
dispatch(resetToMainTabs());
329+
}
326330
dispatch(initialFetchComplete());
327331
dispatch(startEventPolling(initData.queue_id, initData.last_event_id));
328332

src/nav/__tests__/navReducer-test.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/nav/navReducer.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import type { NavigationAction } from 'react-navigation';
33

44
import type { NavigationState, Action } from '../types';
5-
import { getCurrentRouteName } from './navSelectors';
65
import AppNavigator from './AppNavigator';
7-
import { INITIAL_FETCH_COMPLETE } from '../actionConstants';
86

97
/**
108
* Get the initial state for the given route.
@@ -29,9 +27,6 @@ export const initialState = getStateForRoute('loading');
2927

3028
export default (state: NavigationState = initialState, action: Action): NavigationState => {
3129
switch (action.type) {
32-
case INITIAL_FETCH_COMPLETE:
33-
return getCurrentRouteName() === 'main' ? state : getStateForRoute('main');
34-
3530
default: {
3631
// The `react-navigation` libdef says this only takes a NavigationAction,
3732
// but docs say pass arbitrary action. $FlowFixMe

0 commit comments

Comments
 (0)