Chore: Evaluate NewMessageView - TypeScript (#4115)

* Chore: Evaluate NewMessageView - TypeScript

* minor tweak
This commit is contained in:
Reinaldo Neto 2022-05-02 23:43:30 -03:00 committed by GitHub
parent 5d29fcad53
commit bd55fe44ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 11 deletions

View File

@ -206,7 +206,7 @@ export type NewMessageStackParamList = {
buttonText?: string; buttonText?: string;
nextAction?: Function; nextAction?: Function;
}; // TODO: Change }; // TODO: Change
CreateChannelView: { CreateChannelView?: {
isTeam?: boolean; // TODO: To check isTeam?: boolean; // TODO: To check
teamId?: string; teamId?: string;
}; };

View File

@ -20,10 +20,11 @@ import Navigation from '../lib/navigation/appNavigation';
import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion'; import { compareServerVersion } from '../lib/methods/helpers/compareServerVersion';
import UserItem from '../containers/UserItem'; import UserItem from '../containers/UserItem';
import { withTheme } from '../theme'; import { withTheme } from '../theme';
import { goRoom } from '../utils/goRoom'; import { goRoom, TGoRoomItem } from '../utils/goRoom';
import log, { events, logEvent } from '../utils/log'; import log, { events, logEvent } from '../utils/log';
import Touch from '../utils/touch'; import Touch from '../utils/touch';
import sharedStyles from './Styles'; import sharedStyles from './Styles';
import { NewMessageStackParamList } from '../stacks/types';
import { hasPermission, search } from '../lib/methods'; import { hasPermission, search } from '../lib/methods';
const QUERY_SIZE = 50; const QUERY_SIZE = 50;
@ -61,15 +62,15 @@ interface INewMessageViewState {
permissions: boolean[]; permissions: boolean[];
} }
interface INewMessageViewProps extends IBaseScreen<any, 'NewMessageView'> { interface INewMessageViewProps extends IBaseScreen<NewMessageStackParamList, 'NewMessageView'> {
maxUsers: number; maxUsers: number;
isMasterDetail: boolean; isMasterDetail: boolean;
serverVersion: string; serverVersion: string;
createTeamPermission: string[] | undefined; createTeamPermission?: string[];
createDirectMessagePermission: string[] | undefined; createDirectMessagePermission?: string[];
createPublicChannelPermission: string[] | undefined; createPublicChannelPermission?: string[];
createPrivateChannelPermission: string[] | undefined; createPrivateChannelPermission?: string[];
createDiscussionPermission: string[] | undefined; createDiscussionPermission?: string[];
} }
class NewMessageView extends React.Component<INewMessageViewProps, INewMessageViewState> { class NewMessageView extends React.Component<INewMessageViewProps, INewMessageViewState> {
@ -167,8 +168,7 @@ class NewMessageView extends React.Component<INewMessageViewProps, INewMessageVi
}); });
}; };
// TODO: Refactor when migrate room goRoom = (item: TGoRoomItem) => {
goRoom = (item: any) => {
logEvent(events.NEW_MSG_CHAT_WITH_USER); logEvent(events.NEW_MSG_CHAT_WITH_USER);
const { isMasterDetail, navigation } = this.props; const { isMasterDetail, navigation } = this.props;
if (isMasterDetail) { if (isMasterDetail) {
@ -286,7 +286,7 @@ class NewMessageView extends React.Component<INewMessageViewProps, INewMessageVi
<UserItem <UserItem
name={itemSearch.search ? itemSearch.name : itemModel.fname || ''} name={itemSearch.search ? itemSearch.name : itemModel.fname || ''}
username={itemSearch.search ? itemSearch.username : itemModel.name} username={itemSearch.search ? itemSearch.username : itemModel.name}
onPress={() => this.goRoom(item)} onPress={() => this.goRoom(itemModel)}
testID={`new-message-view-item-${item.name}`} testID={`new-message-view-item-${item.name}`}
style={style} style={style}
theme={theme} theme={theme}