diff --git a/app/definitions/index.ts b/app/definitions/index.ts index 6bb354fdf..ea8f9adb4 100644 --- a/app/definitions/index.ts +++ b/app/definitions/index.ts @@ -7,19 +7,4 @@ export interface BaseScreen { theme: string; } -export interface IUser { - _id: string; - name: string; - fname: string; - search?: boolean; - // username is used when is from searching - username?: string; -} - -type UserStatus = 'online' | 'offline'; -export interface ActiveUser { - status: UserStatus; - statusText?: string; -} - export * from './redux'; diff --git a/app/reducers/activeUsers.ts b/app/reducers/activeUsers.ts index 8e16fe25b..6a63dfdf3 100644 --- a/app/reducers/activeUsers.ts +++ b/app/reducers/activeUsers.ts @@ -1,6 +1,12 @@ -import { ActiveUser, ApplicationActions } from '../definitions'; +import { ApplicationActions } from '../definitions'; import { SET_ACTIVE_USERS } from '../actions/actionsTypes'; +type UserStatus = 'online' | 'offline'; +export interface ActiveUser { + status: UserStatus; + statusText?: string; +} + export interface IActiveUsers { [key: string]: ActiveUser; } diff --git a/app/reducers/selectedUsers.ts b/app/reducers/selectedUsers.ts index a31a01f1a..e2be6b9a6 100644 --- a/app/reducers/selectedUsers.ts +++ b/app/reducers/selectedUsers.ts @@ -1,8 +1,17 @@ -import { IUser, ApplicationActions } from '../definitions'; +import { ApplicationActions } from '../definitions'; import { SELECTED_USERS } from '../actions/actionsTypes'; +export interface ISelectedUser { + _id: string; + name: string; + fname: string; + search?: boolean; + // username is used when is from searching + username?: string; +} + export interface ISelectedUsers { - users: IUser[]; + users: ISelectedUser[]; loading: boolean; } diff --git a/app/views/SelectedUsersView.tsx b/app/views/SelectedUsersView.tsx index b22a24649..85b86afe4 100644 --- a/app/views/SelectedUsersView.tsx +++ b/app/views/SelectedUsersView.tsx @@ -14,14 +14,15 @@ import Loading from '../containers/Loading'; import SafeAreaView from '../containers/SafeAreaView'; import SearchBox from '../containers/SearchBox'; import StatusBar from '../containers/StatusBar'; +import { ApplicationState, BaseScreen } from '../definitions'; import I18n from '../i18n'; import database from '../lib/database'; import RocketChat from '../lib/rocketchat'; import UserItem from '../presentation/UserItem'; +import { ISelectedUser } from '../reducers/selectedUsers'; import { getUserSelector } from '../selectors/login'; import { ChatsStackParamList } from '../stacks/types'; import { withTheme } from '../theme'; -import { ApplicationState, BaseScreen, IUser } from '../definitions'; import { showErrorAlert } from '../utils/info'; import log, { events, logEvent } from '../utils/log'; import sharedStyles from './Styles'; @@ -31,14 +32,14 @@ const getItemLayout = (_: any, index: number) => ({ length: ITEM_WIDTH, offset: interface ISelectedUsersViewState { maxUsers?: number; - search: IUser[]; - chats: IUser[]; + search: ISelectedUser[]; + chats: ISelectedUser[]; } interface ISelectedUsersViewProps extends BaseScreen { route: RouteProp; // REDUX STATE - users: IUser[]; + users: ISelectedUser[]; loading: boolean; user: { id: string; @@ -146,7 +147,7 @@ class SelectedUsersView extends React.Component el.name === username) !== -1; }; - toggleUser = (user: IUser) => { + toggleUser = (user: ISelectedUser) => { const { maxUsers } = this.state; const { dispatch, @@ -171,7 +172,7 @@ class SelectedUsersView extends React.Component { + _onPressItem = (id: string, item = {} as ISelectedUser) => { if (item.search) { this.toggleUser({ _id: item._id, name: item.username!, fname: item.name }); } else { @@ -179,7 +180,7 @@ class SelectedUsersView extends React.Component this.toggleUser(item); + _onPressSelectedItem = (item: ISelectedUser) => this.toggleUser(item); renderHeader = () => { const { theme } = this.props; @@ -218,7 +219,7 @@ class SelectedUsersView extends React.Component { + renderSelectedItem = ({ item }: { item: ISelectedUser }) => { const { theme } = this.props; return ( { + renderItem = ({ item, index }: { item: ISelectedUser; index: number }) => { const { search, chats } = this.state; const { theme } = this.props;