diff --git a/app/stacks/MasterDetailStack/types.ts b/app/stacks/MasterDetailStack/types.ts index f06cfd5b9..298d9d343 100644 --- a/app/stacks/MasterDetailStack/types.ts +++ b/app/stacks/MasterDetailStack/types.ts @@ -6,6 +6,7 @@ import { IMessage } from '../../definitions/IMessage'; import { ISubscription, SubscriptionType, TSubscriptionModel } from '../../definitions/ISubscription'; import { ILivechatDepartment } from '../../definitions/ILivechatDepartment'; import { ILivechatTag } from '../../definitions/ILivechatTag'; +import { TServerModel, TThreadModel } from '../../definitions'; export type MasterDetailChatsStackParamList = { RoomView: { @@ -213,9 +214,13 @@ export type MasterDetailInsideStackParamList = { ShareView: { attachments: IAttachment[]; isShareView?: boolean; - serverInfo: {}; + isShareExtension: boolean; + serverInfo: TServerModel; text: string; - room: ISubscription; - thread: any; // TODO: Change + room: TSubscriptionModel; + thread?: TThreadModel; + replying?: boolean; + replyingMessage?: IMessage; + closeReply?: Function; }; }; diff --git a/app/stacks/ShareExtensionStack/types.ts b/app/stacks/ShareExtensionStack/types.ts index 2dc9e120b..8ce94e941 100644 --- a/app/stacks/ShareExtensionStack/types.ts +++ b/app/stacks/ShareExtensionStack/types.ts @@ -3,6 +3,7 @@ import { NavigatorScreenParams } from '@react-navigation/core'; import { TSubscriptionModel } from '../../definitions/ISubscription'; import { TServerModel } from '../../definitions/IServer'; import { IAttachment } from '../../definitions/IAttachment'; +import { IMessage, TThreadModel } from '../../definitions'; export type ShareInsideStackParamList = { ShareListView: undefined; @@ -13,7 +14,10 @@ export type ShareInsideStackParamList = { serverInfo: TServerModel; text: string; room: TSubscriptionModel; - thread?: any; // TODO: Change + thread?: TThreadModel; + replying?: boolean; + replyingMessage?: IMessage; + closeReply?: Function; }; SelectServerView: undefined; }; diff --git a/app/stacks/types.ts b/app/stacks/types.ts index ab62720e6..3e422afa1 100644 --- a/app/stacks/types.ts +++ b/app/stacks/types.ts @@ -3,7 +3,7 @@ import { TextInputProps } from 'react-native'; import { IItem } from '../views/TeamChannelsView'; import { IOptionsField } from '../views/NotificationPreferencesView/options'; -import { IServer } from '../definitions/IServer'; +import { TServerModel } from '../definitions/IServer'; import { IAttachment } from '../definitions/IAttachment'; import { IMessage, TAnyMessageModel, TMessageModel } from '../definitions/IMessage'; import { ISubscription, SubscriptionType, TSubscriptionModel } from '../definitions/ISubscription'; @@ -283,10 +283,10 @@ export type InsideStackParamList = { attachments: IAttachment[]; isShareView?: boolean; isShareExtension: boolean; - serverInfo: IServer; + serverInfo: TServerModel; text: string; room: TSubscriptionModel; - thread: TThreadModel; + thread?: TThreadModel; replying?: boolean; replyingMessage?: IMessage; closeReply?: Function; diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index 5e0bc61f8..d346c095b 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -23,8 +23,8 @@ import { sanitizeLikeString } from '../../lib/database/utils'; import styles from './styles'; import ShareListHeader from './Header'; import { TServerModel, TSubscriptionModel } from '../../definitions'; -import { ShareInsideStackParamList } from '../../definitions/navigationTypes'; import { getRoomAvatar, isAndroid, isIOS } from '../../lib/methods/helpers'; +import { ShareInsideStackParamList } from '../../stacks/ShareExtensionStack/types'; interface IDataFromShare { value: string; @@ -57,10 +57,10 @@ interface INavigationOption { } interface IShareListViewProps extends INavigationOption { - server: string; - token: string; - userId: string; - theme: TSupportedThemes; + server?: string; + token?: string; + userId?: string; + theme?: TSupportedThemes; } const permission: Rationale = { @@ -117,7 +117,7 @@ class ShareListView extends React.Component { const attachments = info.map(file => ({ filename: decodeURIComponent(file.uri.substring(file.uri.lastIndexOf('/') + 1)), description: '', - size: file.size, + size: file.exists ? file.size : null, mime: mime.lookup(file.uri), path: file.uri })) as IFileToShare[]; @@ -187,7 +187,7 @@ class ShareListView extends React.Component { initSearch={this.initSearch} cancelSearch={this.cancelSearch} onChangeSearchText={this.search} - theme={theme} + theme={theme!} /> ) }); @@ -203,7 +203,7 @@ class ShareListView extends React.Component { ) : ( ), - headerTitle: () => , + headerTitle: () => , headerRight: () => searching ? null : ( @@ -255,7 +255,7 @@ class ShareListView extends React.Component { })); }; - getSubscriptions = async (server: string) => { + getSubscriptions = async (server: IShareListViewProps['server']) => { const serversDB = database.servers; if (server) { @@ -348,8 +348,8 @@ class ShareListView extends React.Component { return ( <> - - {I18n.t(header)} + + {I18n.t(header)} @@ -401,8 +401,8 @@ class ShareListView extends React.Component { renderEmptyComponent = () => { const { theme } = this.props; return ( - - {I18n.t('No_results_found')} + + {I18n.t('No_results_found')} ); }; @@ -438,11 +438,11 @@ class ShareListView extends React.Component { return ( - {permission.title} - {permission.message} + {permission.title} + {permission.message} ); @@ -453,8 +453,8 @@ class ShareListView extends React.Component { { } const mapStateToProps = ({ share }: any) => ({ - userId: share.user && share.user.id, - token: share.user && share.user.token, - server: share.server.server + userId: share?.user?.id, + token: share?.user?.token, + server: share?.server?.server }); export default connect(mapStateToProps)(withTheme(ShareListView)); diff --git a/app/views/ShareView/Header.tsx b/app/views/ShareView/Header.tsx index 3032bbbe4..a86998c29 100644 --- a/app/views/ShareView/Header.tsx +++ b/app/views/ShareView/Header.tsx @@ -36,7 +36,7 @@ const styles = StyleSheet.create({ interface IHeader { room: ISubscription; - thread: TThreadModel; + thread?: TThreadModel; } const Header = React.memo(({ room, thread }: IHeader) => { diff --git a/app/views/ShareView/index.tsx b/app/views/ShareView/index.tsx index 8a0dffcb6..fc535f741 100644 --- a/app/views/ShareView/index.tsx +++ b/app/views/ShareView/index.tsx @@ -41,7 +41,7 @@ interface IShareViewState { attachments: IShareAttachment[]; text: string; room: TSubscriptionModel; - thread: TThreadModel; + thread?: TThreadModel; maxFileSize?: number; mediaAllowList?: string; } @@ -49,7 +49,7 @@ interface IShareViewState { interface IShareViewProps { navigation: StackNavigationProp; route: RouteProp; - theme: TSupportedThemes; + theme?: TSupportedThemes; user: { id: string; username: string; @@ -94,7 +94,7 @@ class ShareView extends Component { attachments: [], text: props.route.params?.text ?? '', room: props.route.params?.room ?? {}, - thread: props.route.params?.thread ?? {}, + thread: props.route.params?.thread, maxFileSize: this.isShareExtension ? this.serverInfo?.FileUpload_MaxFileSize : props.FileUpload_MaxFileSize, mediaAllowList: this.isShareExtension ? this.serverInfo?.FileUpload_MediaTypeWhiteList : props.FileUpload_MediaTypeWhiteList }; @@ -124,23 +124,23 @@ class ShareView extends Component { const options: StackNavigationOptions = { headerTitle: () =>
, headerTitleAlign: 'left', - headerTintColor: themes[theme].previewTintColor + headerTintColor: themes[theme!].previewTintColor }; // if is share extension show default back button if (!this.isShareExtension) { - options.headerLeft = () => ; + options.headerLeft = () => ; } if (!attachments.length && !readOnly) { options.headerRight = () => ( - + ); } - options.headerBackground = () => ; + options.headerBackground = () => ; navigation.setOptions(options); }; @@ -331,7 +331,7 @@ class ShareView extends Component { key={selected?.path} item={selected} length={attachments.length} - theme={theme} + theme={theme!} isShareExtension={this.isShareExtension} /> { > { return ( { const { theme } = this.props; if (readOnly || isBlocked(room)) { return ( - - + + {isBlocked(room) ? I18n.t('This_room_is_blocked') : I18n.t('This_room_is_read_only')} ); } return ( - - + + {this.renderContent()} );