diff --git a/app/definitions/navigationTypes.ts b/app/definitions/navigationTypes.ts index 6e2020943..960b35b5d 100644 --- a/app/definitions/navigationTypes.ts +++ b/app/definitions/navigationTypes.ts @@ -1,8 +1,8 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { StackNavigationOptions } from '@react-navigation/stack'; -import { ISubscription } from './ISubscription'; -import { IServer } from './IServer'; +import { TSubscriptionModel } from './ISubscription'; +import { TServerModel } from './IServer'; import { IAttachment } from './IAttachment'; import { MasterDetailInsideStackParamList } from '../stacks/MasterDetailStack/types'; import { OutsideParamList, InsideStackParamList } from '../stacks/types'; @@ -37,10 +37,10 @@ export type ShareInsideStackParamList = { attachments: IAttachment[]; isShareView?: boolean; isShareExtension: boolean; - serverInfo: IServer; + serverInfo: TServerModel; text: string; - room: ISubscription; - thread: any; // TODO: Change + room: TSubscriptionModel; + thread?: any; // TODO: Change }; SelectServerView: undefined; }; diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index c6afa7dc5..0811117e6 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -23,7 +23,8 @@ import SafeAreaView from '../../containers/SafeAreaView'; import { sanitizeLikeString } from '../../lib/database/utils'; import styles from './styles'; import ShareListHeader from './Header'; -import { IServerInfo } from '../../definitions'; +import { TServerModel, TSubscriptionModel } from '../../definitions'; +import { ShareInsideStackParamList } from '../../definitions/navigationTypes'; import { getRoomAvatar } from '../../lib/methods'; interface IDataFromShare { @@ -35,39 +36,25 @@ interface IFileToShare { filename: string; description: string; size: number; - mime: any; + mime: string; path: string; } -interface IChat { - rid: string; - t: string; - name: string; - fname: string; - blocked: boolean; - blocker: boolean; - prid: string; - uids: string[]; - usernames: string[]; - topic: string; - description: string; -} - interface IState { searching: boolean; searchText: string; - searchResults: IChat[]; - chats: IChat[]; + searchResults: TSubscriptionModel[]; + chats: TSubscriptionModel[]; serversCount: number; attachments: IFileToShare[]; text: string; loading: boolean; - serverInfo: IServerInfo; + serverInfo: TServerModel; needsPermission: boolean; } interface INavigationOption { - navigation: StackNavigationProp; + navigation: StackNavigationProp; } interface IShareListViewProps extends INavigationOption { @@ -84,7 +71,7 @@ const permission: Rationale = { }; const getItemLayout = (data: any, index: number) => ({ length: data.length, offset: ROW_HEIGHT * index, index }); -const keyExtractor = (item: IChat) => item.rid; +const keyExtractor = (item: TSubscriptionModel) => item.rid; class ShareListView extends React.Component { private unsubscribeFocus: (() => void) | undefined; @@ -102,7 +89,7 @@ class ShareListView extends React.Component { attachments: [], text: '', loading: true, - serverInfo: {} as IServerInfo, + serverInfo: {} as TServerModel, needsPermission: isAndroid || false }; this.setHeader(); @@ -252,7 +239,7 @@ class ShareListView extends React.Component { const data = (await db .get('subscriptions') .query(...defaultWhereClause) - .fetch()) as IChat[]; + .fetch()) as TSubscriptionModel[]; return data.map(item => ({ rid: item.rid, @@ -307,12 +294,12 @@ class ShareListView extends React.Component { uriToPath = (uri: string) => decodeURIComponent(isIOS ? uri.replace(/^file:\/\//, '') : uri); - getRoomTitle = (item: IChat) => { + getRoomTitle = (item: TSubscriptionModel) => { const { serverInfo } = this.state; return ((item.prid || serverInfo?.useRealName) && item.fname) || item.name; }; - shareMessage = (room: IChat) => { + shareMessage = (room: TSubscriptionModel) => { const { attachments, text, serverInfo } = this.state; const { navigation } = this.props; @@ -369,7 +356,7 @@ class ShareListView extends React.Component { ); }; - renderItem = ({ item }: { item: IChat }) => { + renderItem = ({ item }: { item: TSubscriptionModel }) => { const { serverInfo } = this.state; let description; switch (item.t) {