/* @flow */
import { REHYDRATE } from 'redux-persist/constants';

import type { NavigationState, Action } from '../types';
import { getFirstIfDeepEqual } from '../utils/immutability';
import { navigateToChat } from './navActions';
import { getStateForRoute, getInitialNavState } from './navSelectors';
import AppNavigator from './AppNavigator';
import {
  INITIAL_FETCH_COMPLETE,
  ACCOUNT_SWITCH,
  LOGIN_SUCCESS,
  LOGOUT,
  SWITCH_NARROW,
} from '../actionConstants';

export default (
  state: NavigationState = getStateForRoute('loading'),
  action: Action,
): NavigationState => {
  switch (action.type) {
    case REHYDRATE:
      return getInitialNavState(action.payload);

    case ACCOUNT_SWITCH:
      return getStateForRoute('loading');

    case LOGIN_SUCCESS:
      return getStateForRoute('main');

    case INITIAL_FETCH_COMPLETE:
      return getFirstIfDeepEqual(
        state,
        getStateForRoute('main'),
        (a, b) => state.routes[0].routeName === 'main',
      );

    case LOGOUT:
      return getStateForRoute('account');

    case SWITCH_NARROW:
      return AppNavigator.router.getStateForAction(navigateToChat(action.narrow), state);

    default:
      return AppNavigator.router.getStateForAction(action, state);
  }
};

@@ -120,69 +120,8 @@
 s';%0A
-import %7B getFirstIfDeepEqual %7D from '../utils/immutability';%0A
 impo
@@ -796,77 +796,46 @@
 urn 
-getFirstIfDeepEqual(%0A        state,%0A        getStateForRoute(
+state.routes%5B0%5D.routeName === 
 'main'
-),
+ ?
 %0A   
@@ -843,62 +843,39 @@
     
-(a, b) =%3E state.routes%5B0%5D.routeName === 'main',%0A      
+state : getStateForRoute('main'
 );%0A%0A

Simplify out vacuous use of "getFirstIfDeepEqual".