Skip to content

Commit

Permalink
flow: Fix NavigateAction type
Browse files Browse the repository at this point in the history
The type `NavigationNavigateAction` we use is too specific and
not the correct one. We want the `NavigationAction` type instead.

Also, to make it simpler and consistent, we rename our own type
`NavigateAction` to `NavigationAction`.
  • Loading branch information
borisyankov committed Sep 20, 2018
1 parent 2a5f542 commit f6f6375
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
6 changes: 2 additions & 4 deletions src/actionTypes.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* @flow */
import type { NavigationNavigateAction } from 'react-navigation';

import {
REHYDRATE,
APP_ONLINE,
Expand Down Expand Up @@ -89,6 +87,8 @@ import type {
MuteState,
} from './types';

export type { NavigationAction } from 'react-navigation';

/**
* Dispatched by redux-persist when the stored state is loaded.
*
Expand Down Expand Up @@ -151,8 +151,6 @@ export type DebugFlagToggleAction = {
value: string,
};

export type NavigateAction = NavigationNavigateAction;

export type AccountSwitchAction = {
type: typeof ACCOUNT_SWITCH,
index: number,
Expand Down
69 changes: 35 additions & 34 deletions src/nav/navActions.js
Original file line number Diff line number Diff line change
@@ -1,101 +1,102 @@
/* @flow */
import { NavigationActions } from 'react-navigation';

import type { NavigateAction, Message, Narrow, ApiServerSettings } from '../types';
import type { NavigationAction, Message, Narrow, ApiServerSettings } from '../types';

export const navigateBack = (): NavigateAction => NavigationActions.back();
export const navigateBack = (): NavigationAction => NavigationActions.back();

export const navigateToChat = (narrow: Narrow): NavigateAction =>
export const navigateToChat = (narrow: Narrow): NavigationAction =>
NavigationActions.navigate({ routeName: 'chat', params: { narrow } });

export const navigateToAllStreams = (): NavigateAction =>
export const navigateToAllStreams = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'subscriptions' });

export const navigateToUsersScreen = (): NavigateAction =>
export const navigateToUsersScreen = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'users' });

export const navigateToSearch = (): NavigateAction =>
export const navigateToSearch = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'search' });

export const navigateToSettings = (): NavigateAction =>
export const navigateToSettings = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'settings' });

export const navigateToEmojiPicker = (messageId: number): NavigateAction =>
export const navigateToEmojiPicker = (messageId: number): NavigationAction =>
NavigationActions.navigate({ routeName: 'emoji-picker', params: { messageId } });

export const navigateToAuth = (serverSettings: ApiServerSettings): NavigateAction =>
export const navigateToAuth = (serverSettings: ApiServerSettings): NavigationAction =>
NavigationActions.navigate({ routeName: 'auth', params: { serverSettings } });

export const navigateToDev = (): NavigateAction => NavigationActions.navigate({ routeName: 'dev' });
export const navigateToDev = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'dev' });

export const navigateToPassword = (requireEmailFormat: boolean): NavigateAction =>
export const navigateToPassword = (requireEmailFormat: boolean): NavigationAction =>
NavigationActions.navigate({ routeName: 'password', params: { requireEmailFormat } });

export const navigateToAccountPicker = (): NavigateAction =>
export const navigateToAccountPicker = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'account' });

export const navigateToAccountDetails = (email: string): NavigateAction =>
export const navigateToAccountDetails = (email: string): NavigationAction =>
NavigationActions.navigate({ routeName: 'account-details', params: { email } });

export const navigateToGroupDetails = (recipients: string[]): NavigateAction =>
export const navigateToGroupDetails = (recipients: string[]): NavigationAction =>
NavigationActions.navigate({ routeName: 'group-details', params: { recipients } });

export const navigateToAddNewAccount = (realm: string): NavigateAction =>
export const navigateToAddNewAccount = (realm: string): NavigationAction =>
NavigationActions.navigate({ routeName: 'realm', params: { realm } });

export const navigateToLightbox = (src: string, message: Message): NavigateAction =>
export const navigateToLightbox = (src: string, message: Message): NavigationAction =>
NavigationActions.navigate({ routeName: 'lightbox', params: { src, message } });

export const navigateToLoading = (): NavigateAction =>
export const navigateToLoading = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'loading' });

export const navigateToLanguage = (): NavigateAction =>
export const navigateToLanguage = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'language' });

export const navigateToCreateGroup = (): NavigateAction =>
export const navigateToCreateGroup = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'group' });

export const navigateToDiagnostics = (): NavigateAction =>
export const navigateToDiagnostics = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'diagnostics' });

export const navigateToWelcomeHelp = (): NavigateAction =>
export const navigateToWelcomeHelp = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'welcome-help' });

export const navigateToWelcomeScreen = (): NavigateAction =>
export const navigateToWelcomeScreen = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'welcome' });

export const navigateToVariables = (): NavigateAction =>
export const navigateToVariables = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'variables' });

export const navigateToTiming = (): NavigateAction =>
export const navigateToTiming = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'timing' });

export const navigateToStorage = (): NavigateAction =>
export const navigateToStorage = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'storage' });

export const navigateToDebug = (): NavigateAction =>
export const navigateToDebug = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'debug' });

export const navigateToNotifDiag = (): NavigateAction =>
export const navigateToNotifDiag = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'notifDiag' });

export const navigateToStream = (streamId: number): NavigateAction =>
export const navigateToStream = (streamId: number): NavigationAction =>
NavigationActions.navigate({ routeName: 'stream', params: { streamId } });

export const navigateToTopicList = (streamId: number): NavigateAction =>
export const navigateToTopicList = (streamId: number): NavigationAction =>
NavigationActions.navigate({ routeName: 'topics', params: { streamId } });

export const navigateToCreateStream = (): NavigateAction =>
export const navigateToCreateStream = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'stream-create' });

export const navigateToEditStream = (streamId: number): NavigateAction =>
export const navigateToEditStream = (streamId: number): NavigationAction =>
NavigationActions.navigate({ routeName: 'stream-edit', params: { streamId } });

export const navigateToStreamSubscribers = (streamId: number): NavigateAction =>
export const navigateToStreamSubscribers = (streamId: number): NavigationAction =>
NavigationActions.navigate({ routeName: 'invite-users', params: { streamId } });

export const navigateToNotifications = (): NavigateAction =>
export const navigateToNotifications = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'notifications' });

export const navigateToLegal = (): NavigateAction =>
export const navigateToLegal = (): NavigationAction =>
NavigationActions.navigate({ routeName: 'legal' });

0 comments on commit f6f6375

Please sign in to comment.