Fix ShareView and ShareListView types
This commit is contained in:
parent
f60a9f6332
commit
221702520c
|
@ -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;
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<IShareListViewProps, IState> {
|
|||
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<IShareListViewProps, IState> {
|
|||
initSearch={this.initSearch}
|
||||
cancelSearch={this.cancelSearch}
|
||||
onChangeSearchText={this.search}
|
||||
theme={theme}
|
||||
theme={theme!}
|
||||
/>
|
||||
)
|
||||
});
|
||||
|
@ -203,7 +203,7 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
) : (
|
||||
<HeaderButton.CancelModal onPress={ShareExtension.close} testID='share-extension-close' />
|
||||
),
|
||||
headerTitle: () => <ShareListHeader searching={searching} onChangeSearchText={this.search} theme={theme} />,
|
||||
headerTitle: () => <ShareListHeader searching={searching} onChangeSearchText={this.search} theme={theme!} />,
|
||||
headerRight: () =>
|
||||
searching ? null : (
|
||||
<HeaderButton.Container>
|
||||
|
@ -255,7 +255,7 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
}));
|
||||
};
|
||||
|
||||
getSubscriptions = async (server: string) => {
|
||||
getSubscriptions = async (server: IShareListViewProps['server']) => {
|
||||
const serversDB = database.servers;
|
||||
|
||||
if (server) {
|
||||
|
@ -348,8 +348,8 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
|
||||
return (
|
||||
<>
|
||||
<View style={[styles.headerContainer, { backgroundColor: themes[theme].auxiliaryBackground }]}>
|
||||
<Text style={[styles.headerText, { color: themes[theme].titleText }]}>{I18n.t(header)}</Text>
|
||||
<View style={[styles.headerContainer, { backgroundColor: themes[theme!].auxiliaryBackground }]}>
|
||||
<Text style={[styles.headerText, { color: themes[theme!].titleText }]}>{I18n.t(header)}</Text>
|
||||
</View>
|
||||
<List.Separator />
|
||||
</>
|
||||
|
@ -401,8 +401,8 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
renderEmptyComponent = () => {
|
||||
const { theme } = this.props;
|
||||
return (
|
||||
<View style={[styles.container, styles.emptyContainer, { backgroundColor: themes[theme].auxiliaryBackground }]}>
|
||||
<Text style={[styles.title, { color: themes[theme].titleText }]}>{I18n.t('No_results_found')}</Text>
|
||||
<View style={[styles.container, styles.emptyContainer, { backgroundColor: themes[theme!].auxiliaryBackground }]}>
|
||||
<Text style={[styles.title, { color: themes[theme!].titleText }]}>{I18n.t('No_results_found')}</Text>
|
||||
</View>
|
||||
);
|
||||
};
|
||||
|
@ -438,11 +438,11 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
return (
|
||||
<SafeAreaView>
|
||||
<ScrollView
|
||||
style={{ backgroundColor: themes[theme].backgroundColor }}
|
||||
contentContainerStyle={[styles.container, styles.centered, { backgroundColor: themes[theme].backgroundColor }]}
|
||||
style={{ backgroundColor: themes[theme!].backgroundColor }}
|
||||
contentContainerStyle={[styles.container, styles.centered, { backgroundColor: themes[theme!].backgroundColor }]}
|
||||
>
|
||||
<Text style={[styles.permissionTitle, { color: themes[theme].titleText }]}>{permission.title}</Text>
|
||||
<Text style={[styles.permissionMessage, { color: themes[theme].bodyText }]}>{permission.message}</Text>
|
||||
<Text style={[styles.permissionTitle, { color: themes[theme!].titleText }]}>{permission.title}</Text>
|
||||
<Text style={[styles.permissionMessage, { color: themes[theme!].bodyText }]}>{permission.message}</Text>
|
||||
</ScrollView>
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
@ -453,8 +453,8 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
<FlatList
|
||||
data={searching ? searchResults : chats}
|
||||
keyExtractor={keyExtractor}
|
||||
style={[styles.flatlist, { backgroundColor: themes[theme].auxiliaryBackground }]}
|
||||
contentContainerStyle={{ backgroundColor: themes[theme].backgroundColor }}
|
||||
style={[styles.flatlist, { backgroundColor: themes[theme!].auxiliaryBackground }]}
|
||||
contentContainerStyle={{ backgroundColor: themes[theme!].backgroundColor }}
|
||||
renderItem={this.renderItem}
|
||||
getItemLayout={getItemLayout}
|
||||
ItemSeparatorComponent={List.Separator}
|
||||
|
@ -470,9 +470,9 @@ class ShareListView extends React.Component<IShareListViewProps, IState> {
|
|||
}
|
||||
|
||||
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));
|
||||
|
|
|
@ -36,7 +36,7 @@ const styles = StyleSheet.create({
|
|||
|
||||
interface IHeader {
|
||||
room: ISubscription;
|
||||
thread: TThreadModel;
|
||||
thread?: TThreadModel;
|
||||
}
|
||||
|
||||
const Header = React.memo(({ room, thread }: IHeader) => {
|
||||
|
|
|
@ -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<InsideStackParamList, 'ShareView'>;
|
||||
route: RouteProp<InsideStackParamList, 'ShareView'>;
|
||||
theme: TSupportedThemes;
|
||||
theme?: TSupportedThemes;
|
||||
user: {
|
||||
id: string;
|
||||
username: string;
|
||||
|
@ -94,7 +94,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
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<IShareViewProps, IShareViewState> {
|
|||
const options: StackNavigationOptions = {
|
||||
headerTitle: () => <Header room={room} thread={thread} />,
|
||||
headerTitleAlign: 'left',
|
||||
headerTintColor: themes[theme].previewTintColor
|
||||
headerTintColor: themes[theme!].previewTintColor
|
||||
};
|
||||
|
||||
// if is share extension show default back button
|
||||
if (!this.isShareExtension) {
|
||||
options.headerLeft = () => <HeaderButton.CloseModal navigation={navigation} color={themes[theme].previewTintColor} />;
|
||||
options.headerLeft = () => <HeaderButton.CloseModal navigation={navigation} color={themes[theme!].previewTintColor} />;
|
||||
}
|
||||
|
||||
if (!attachments.length && !readOnly) {
|
||||
options.headerRight = () => (
|
||||
<HeaderButton.Container>
|
||||
<HeaderButton.Item title={I18n.t('Send')} onPress={this.send} color={themes[theme].previewTintColor} />
|
||||
<HeaderButton.Item title={I18n.t('Send')} onPress={this.send} color={themes[theme!].previewTintColor} />
|
||||
</HeaderButton.Container>
|
||||
);
|
||||
}
|
||||
|
||||
options.headerBackground = () => <View style={[styles.container, { backgroundColor: themes[theme].previewBackground }]} />;
|
||||
options.headerBackground = () => <View style={[styles.container, { backgroundColor: themes[theme!].previewBackground }]} />;
|
||||
|
||||
navigation.setOptions(options);
|
||||
};
|
||||
|
@ -331,7 +331,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
key={selected?.path}
|
||||
item={selected}
|
||||
length={attachments.length}
|
||||
theme={theme}
|
||||
theme={theme!}
|
||||
isShareExtension={this.isShareExtension}
|
||||
/>
|
||||
<MessageBox
|
||||
|
@ -351,7 +351,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
>
|
||||
<Thumbs
|
||||
attachments={attachments}
|
||||
theme={theme}
|
||||
theme={theme!}
|
||||
isShareExtension={this.isShareExtension}
|
||||
onPress={this.selectFile}
|
||||
onRemove={this.removeFile}
|
||||
|
@ -364,7 +364,7 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
return (
|
||||
<FormTextInput
|
||||
containerStyle={styles.inputContainer}
|
||||
inputStyle={[styles.input, styles.textInput, { backgroundColor: themes[theme].focusedBackground }]}
|
||||
inputStyle={[styles.input, styles.textInput, { backgroundColor: themes[theme!].focusedBackground }]}
|
||||
placeholder=''
|
||||
onChangeText={this.onChangeText}
|
||||
defaultValue=''
|
||||
|
@ -382,16 +382,16 @@ class ShareView extends Component<IShareViewProps, IShareViewState> {
|
|||
const { theme } = this.props;
|
||||
if (readOnly || isBlocked(room)) {
|
||||
return (
|
||||
<View style={[styles.container, styles.centered, { backgroundColor: themes[theme].backgroundColor }]}>
|
||||
<Text style={[styles.title, { color: themes[theme].titleText }]}>
|
||||
<View style={[styles.container, styles.centered, { backgroundColor: themes[theme!].backgroundColor }]}>
|
||||
<Text style={[styles.title, { color: themes[theme!].titleText }]}>
|
||||
{isBlocked(room) ? I18n.t('This_room_is_blocked') : I18n.t('This_room_is_read_only')}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
||||
<StatusBar barStyle='light-content' backgroundColor={themes[theme].previewBackground} />
|
||||
<SafeAreaView style={{ backgroundColor: themes[theme!].backgroundColor }}>
|
||||
<StatusBar barStyle='light-content' backgroundColor={themes[theme!].previewBackground} />
|
||||
{this.renderContent()}
|
||||
</SafeAreaView>
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue