Skip to content

Commit

Permalink
navActions: Stop dispatching navigateToAccountDetails() via Redux.
Browse files Browse the repository at this point in the history
Instead, dispatch it via our recently added `NavigationService`.
  • Loading branch information
chrisbobbe committed Oct 20, 2020
1 parent cbfd4e6 commit 5fe7c6e
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/chat/GroupDetailsScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { PureComponent } from 'react';
import { FlatList } from 'react-native';
import type { NavigationStackProp, NavigationStateRoute } from 'react-navigation-stack';

import NavigationService from '../nav/NavigationService';
import type { Dispatch, UserOrBot } from '../types';
import { connect } from '../react-redux';
import { Screen } from '../common';
Expand All @@ -24,7 +25,7 @@ type Props = $ReadOnly<{|

class GroupDetailsScreen extends PureComponent<Props> {
handlePress = (userId: number) => {
this.props.dispatch(navigateToAccountDetails(userId));
NavigationService.dispatch(navigateToAccountDetails(userId));
};

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/reactions/ReactionUserList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { PureComponent } from 'react';
import { FlatList } from 'react-native';
import { connect } from '../react-redux';

import NavigationService from '../nav/NavigationService';
import type { Dispatch, UserOrBot } from '../types';
import UserItem from '../users/UserItem';
import { navigateToAccountDetails } from '../actions';
Expand All @@ -20,8 +21,7 @@ type Props = $ReadOnly<{|
*/
class ReactionUserList extends PureComponent<Props> {
handlePress = (userId: number) => {
const { dispatch } = this.props;
dispatch(navigateToAccountDetails(userId));
NavigationService.dispatch(navigateToAccountDetails(userId));
};

render() {
Expand Down
5 changes: 3 additions & 2 deletions src/title-buttons/InfoNavButtonPrivate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import React, { PureComponent } from 'react';

import NavigationService from '../nav/NavigationService';
import type { Dispatch, Narrow } from '../types';
import { connect } from '../react-redux';
import NavButton from '../nav/NavButton';
Expand All @@ -21,8 +22,8 @@ type Props = $ReadOnly<{|

class InfoNavButtonPrivate extends PureComponent<Props> {
handlePress = () => {
const { dispatch, userId } = this.props;
dispatch(navigateToAccountDetails(userId));
const { userId } = this.props;
NavigationService.dispatch(navigateToAccountDetails(userId));
};

render() {
Expand Down
4 changes: 2 additions & 2 deletions src/title/TitleGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { PureComponent } from 'react';
import { View } from 'react-native';

import NavigationService from '../nav/NavigationService';
import type { Dispatch, UserOrBot, Narrow } from '../types';
import styles, { createStyleSheet } from '../styles';
import { connect } from '../react-redux';
Expand All @@ -23,8 +24,7 @@ type Props = $ReadOnly<{|

class TitleGroup extends PureComponent<Props> {
handlePress = (user: UserOrBot) => {
const { dispatch } = this.props;
dispatch(navigateToAccountDetails(user.user_id));
NavigationService.dispatch(navigateToAccountDetails(user.user_id));
};

styles = createStyleSheet({
Expand Down
5 changes: 3 additions & 2 deletions src/title/TitlePrivate.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React, { PureComponent } from 'react';
import { Text, View } from 'react-native';

import NavigationService from '../nav/NavigationService';
import type { Dispatch, UserOrBot } from '../types';
import styles, { createStyleSheet } from '../styles';
import { connect } from '../react-redux';
Expand All @@ -26,11 +27,11 @@ type Props = $ReadOnly<{

class TitlePrivate extends PureComponent<Props> {
handlePress = () => {
const { dispatch, user } = this.props;
const { user } = this.props;
if (!user) {
return;
}
dispatch(navigateToAccountDetails(user.user_id));
NavigationService.dispatch(navigateToAccountDetails(user.user_id));
};

styles = createStyleSheet({
Expand Down
7 changes: 4 additions & 3 deletions src/webview/webViewEventHandlers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* @flow strict-local */
import { Clipboard, Alert } from 'react-native';

import NavigationService from '../nav/NavigationService';
import * as api from '../api';
import config from '../config';
import type { Dispatch, GetText, Message, Narrow, Outbox, EditMessage } from '../types';
Expand Down Expand Up @@ -222,7 +224,7 @@ export const handleMessageListEvent = (props: Props, _: GetText, event: MessageL
break;

case 'avatar': {
props.dispatch(navigateToAccountDetails(event.fromUserId));
NavigationService.dispatch(navigateToAccountDetails(event.fromUserId));
break;
}

Expand Down Expand Up @@ -267,8 +269,7 @@ export const handleMessageListEvent = (props: Props, _: GetText, event: MessageL
break;

case 'mention': {
const { dispatch } = props;
dispatch(navigateToAccountDetails(event.userId));
NavigationService.dispatch(navigateToAccountDetails(event.userId));
break;
}

Expand Down

0 comments on commit 5fe7c6e

Please sign in to comment.