2020-06-26 20:22:56 +00:00
|
|
|
import React, { Component } from 'react';
|
2021-11-16 16:19:50 +00:00
|
|
|
import { StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack';
|
|
|
|
import { RouteProp } from '@react-navigation/native';
|
2024-01-25 14:11:07 +00:00
|
|
|
import { Text, View } from 'react-native';
|
2019-07-18 17:44:02 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import ShareExtension from 'rn-extensions-share';
|
2021-12-13 16:27:01 +00:00
|
|
|
import { Q } from '@nozbe/watermelondb';
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2024-01-25 14:11:07 +00:00
|
|
|
import { IMessageComposerRef, MessageComposerContainer } from '../../containers/MessageComposer';
|
2021-12-03 19:27:57 +00:00
|
|
|
import { InsideStackParamList } from '../../stacks/types';
|
2022-04-07 14:10:03 +00:00
|
|
|
import { themes } from '../../lib/constants';
|
2019-07-18 17:44:02 +00:00
|
|
|
import I18n from '../../i18n';
|
2024-01-25 14:11:07 +00:00
|
|
|
import { prepareQuoteMessage } from '../../containers/MessageComposer/helpers';
|
2022-08-19 21:14:37 +00:00
|
|
|
import { sendLoadingEvent } from '../../containers/Loading';
|
2020-10-30 16:15:58 +00:00
|
|
|
import * as HeaderButton from '../../containers/HeaderButton';
|
2022-04-12 16:27:05 +00:00
|
|
|
import { TSupportedThemes, withTheme } from '../../theme';
|
2022-06-27 18:46:59 +00:00
|
|
|
import { FormTextInput } from '../../containers/TextInput';
|
2020-06-26 20:22:56 +00:00
|
|
|
import SafeAreaView from '../../containers/SafeAreaView';
|
|
|
|
import { getUserSelector } from '../../selectors/login';
|
|
|
|
import StatusBar from '../../containers/StatusBar';
|
|
|
|
import database from '../../lib/database';
|
2021-09-13 20:41:05 +00:00
|
|
|
import Thumbs from './Thumbs';
|
|
|
|
import Preview from './Preview';
|
|
|
|
import Header from './Header';
|
|
|
|
import styles from './styles';
|
2024-01-25 14:11:07 +00:00
|
|
|
import { IApplicationState, IServer, IShareAttachment, IUser, TSubscriptionModel, TThreadModel } from '../../definitions';
|
2022-06-06 14:17:51 +00:00
|
|
|
import { sendFileMessage, sendMessage } from '../../lib/methods';
|
2022-06-27 18:46:59 +00:00
|
|
|
import { hasPermission, isAndroid, canUploadFile, isReadOnly, isBlocked } from '../../lib/methods/helpers';
|
2024-01-25 14:11:07 +00:00
|
|
|
import { RoomContext } from '../RoomView/context';
|
2021-11-16 16:19:50 +00:00
|
|
|
|
|
|
|
interface IShareViewState {
|
2022-05-11 17:59:29 +00:00
|
|
|
selected: IShareAttachment;
|
2021-11-16 16:19:50 +00:00
|
|
|
loading: boolean;
|
|
|
|
readOnly: boolean;
|
2022-05-11 17:59:29 +00:00
|
|
|
attachments: IShareAttachment[];
|
2021-11-16 16:19:50 +00:00
|
|
|
text: string;
|
2022-03-02 14:18:01 +00:00
|
|
|
room: TSubscriptionModel;
|
2023-08-18 17:48:33 +00:00
|
|
|
thread: TThreadModel;
|
2022-05-11 17:59:29 +00:00
|
|
|
maxFileSize?: number;
|
|
|
|
mediaAllowList?: string;
|
2021-11-16 16:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IShareViewProps {
|
2021-12-03 19:27:57 +00:00
|
|
|
navigation: StackNavigationProp<InsideStackParamList, 'ShareView'>;
|
|
|
|
route: RouteProp<InsideStackParamList, 'ShareView'>;
|
2023-08-18 17:48:33 +00:00
|
|
|
theme: TSupportedThemes;
|
2021-11-16 16:19:50 +00:00
|
|
|
user: {
|
|
|
|
id: string;
|
|
|
|
username: string;
|
|
|
|
token: string;
|
|
|
|
};
|
|
|
|
server: string;
|
2022-01-12 12:54:04 +00:00
|
|
|
FileUpload_MediaTypeWhiteList?: string;
|
2021-11-16 16:19:50 +00:00
|
|
|
FileUpload_MaxFileSize?: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
class ShareView extends Component<IShareViewProps, IShareViewState> {
|
2024-01-25 14:11:07 +00:00
|
|
|
private messageComposerRef: React.RefObject<IMessageComposerRef>;
|
2021-11-16 16:19:50 +00:00
|
|
|
private files: any[];
|
|
|
|
private isShareExtension: boolean;
|
2022-05-11 17:59:29 +00:00
|
|
|
private serverInfo: IServer;
|
2023-01-05 18:23:11 +00:00
|
|
|
private closeReply?: Function;
|
2021-11-16 16:19:50 +00:00
|
|
|
|
|
|
|
constructor(props: IShareViewProps) {
|
2019-07-18 17:44:02 +00:00
|
|
|
super(props);
|
2024-01-25 14:11:07 +00:00
|
|
|
this.messageComposerRef = React.createRef();
|
2020-06-26 20:22:56 +00:00
|
|
|
this.files = props.route.params?.attachments ?? [];
|
|
|
|
this.isShareExtension = props.route.params?.isShareExtension;
|
|
|
|
this.serverInfo = props.route.params?.serverInfo ?? {};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
|
|
|
this.state = {
|
2022-05-11 17:59:29 +00:00
|
|
|
selected: {} as IShareAttachment,
|
2019-07-18 17:44:02 +00:00
|
|
|
loading: false,
|
2020-04-13 12:51:16 +00:00
|
|
|
readOnly: false,
|
2020-06-26 20:22:56 +00:00
|
|
|
attachments: [],
|
|
|
|
text: props.route.params?.text ?? '',
|
|
|
|
room: props.route.params?.room ?? {},
|
2023-08-18 17:48:33 +00:00
|
|
|
thread: props.route.params?.thread ?? {},
|
2020-06-26 20:22:56 +00:00
|
|
|
maxFileSize: this.isShareExtension ? this.serverInfo?.FileUpload_MaxFileSize : props.FileUpload_MaxFileSize,
|
|
|
|
mediaAllowList: this.isShareExtension ? this.serverInfo?.FileUpload_MediaTypeWhiteList : props.FileUpload_MediaTypeWhiteList
|
2019-07-18 17:44:02 +00:00
|
|
|
};
|
2020-06-26 20:22:56 +00:00
|
|
|
this.getServerInfo();
|
|
|
|
}
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
componentDidMount = async () => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const readOnly = await this.getReadOnly();
|
|
|
|
const { attachments, selected } = await this.getAttachments();
|
|
|
|
this.setState({ readOnly, attachments, selected }, () => this.setHeader());
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-04-13 12:51:16 +00:00
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
componentWillUnmount = () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
console.countReset(`${this.constructor.name}.render calls`);
|
2023-01-05 18:23:11 +00:00
|
|
|
// close reply from the RoomView
|
|
|
|
setTimeout(() => {
|
|
|
|
if (this.closeReply) {
|
|
|
|
this.closeReply();
|
|
|
|
}
|
|
|
|
}, 300);
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2020-06-15 14:00:46 +00:00
|
|
|
setHeader = () => {
|
2021-09-13 20:41:05 +00:00
|
|
|
const { room, thread, readOnly, attachments } = this.state;
|
2020-06-26 20:22:56 +00:00
|
|
|
const { navigation, theme } = this.props;
|
|
|
|
|
2021-11-16 16:19:50 +00:00
|
|
|
const options: StackNavigationOptions = {
|
2020-06-26 20:22:56 +00:00
|
|
|
headerTitle: () => <Header room={room} thread={thread} />,
|
|
|
|
headerTitleAlign: 'left',
|
2023-08-18 17:48:33 +00:00
|
|
|
headerTintColor: themes[theme].previewTintColor
|
2020-06-26 20:22:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// if is share extension show default back button
|
|
|
|
if (!this.isShareExtension) {
|
2023-08-18 17:48:33 +00:00
|
|
|
options.headerLeft = () => <HeaderButton.CloseModal navigation={navigation} color={themes[theme].previewTintColor} />;
|
2020-06-26 20:22:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!attachments.length && !readOnly) {
|
|
|
|
options.headerRight = () => (
|
2020-10-30 16:15:58 +00:00
|
|
|
<HeaderButton.Container>
|
2023-08-18 17:48:33 +00:00
|
|
|
<HeaderButton.Item title={I18n.t('Send')} onPress={this.send} color={themes[theme].previewTintColor} />
|
2020-10-30 16:15:58 +00:00
|
|
|
</HeaderButton.Container>
|
2020-06-26 20:22:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-08-18 17:48:33 +00:00
|
|
|
options.headerBackground = () => <View style={[styles.container, { backgroundColor: themes[theme].previewBackground }]} />;
|
2020-06-26 20:22:56 +00:00
|
|
|
|
|
|
|
navigation.setOptions(options);
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-06-26 20:22:56 +00:00
|
|
|
|
|
|
|
// fetch server info
|
2021-09-13 20:41:05 +00:00
|
|
|
getServerInfo = async () => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { server } = this.props;
|
|
|
|
const serversDB = database.servers;
|
2021-02-26 16:25:51 +00:00
|
|
|
const serversCollection = serversDB.get('servers');
|
2020-06-26 20:22:56 +00:00
|
|
|
try {
|
|
|
|
this.serverInfo = await serversCollection.find(server);
|
|
|
|
} catch (error) {
|
|
|
|
// Do nothing
|
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2020-04-13 12:51:16 +00:00
|
|
|
|
2021-12-13 16:27:01 +00:00
|
|
|
getPermissionMobileUpload = async () => {
|
|
|
|
const { room } = this.state;
|
|
|
|
const db = database.active;
|
|
|
|
const permissionsCollection = db.get('permissions');
|
|
|
|
const uploadFilePermissionFetch = await permissionsCollection.query(Q.where('id', Q.like('mobile-upload-file'))).fetch();
|
|
|
|
const uploadFilePermission = uploadFilePermissionFetch[0]?.roles;
|
2022-04-28 20:37:25 +00:00
|
|
|
const permissionToUpload = await hasPermission([uploadFilePermission], room.rid);
|
2021-12-13 16:27:01 +00:00
|
|
|
// uploadFilePermission as undefined is considered that there isn't this permission, so all can upload file.
|
|
|
|
return !uploadFilePermission || permissionToUpload[0];
|
|
|
|
};
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
getReadOnly = async () => {
|
2019-07-18 17:44:02 +00:00
|
|
|
const { room } = this.state;
|
2020-06-15 14:00:46 +00:00
|
|
|
const { user } = this.props;
|
2022-03-02 14:18:01 +00:00
|
|
|
const readOnly = await isReadOnly(room, user.username);
|
2020-06-26 20:22:56 +00:00
|
|
|
return readOnly;
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
getAttachments = async () => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { mediaAllowList, maxFileSize } = this.state;
|
2021-12-13 16:27:01 +00:00
|
|
|
const permissionToUploadFile = await this.getPermissionMobileUpload();
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const items = await Promise.all(
|
|
|
|
this.files.map(async item => {
|
|
|
|
// Check server settings
|
2022-05-11 17:59:29 +00:00
|
|
|
const { success: canUpload, error } = canUploadFile({
|
|
|
|
file: item,
|
|
|
|
allowList: mediaAllowList,
|
|
|
|
maxFileSize,
|
|
|
|
permissionToUploadFile
|
|
|
|
});
|
2021-09-13 20:41:05 +00:00
|
|
|
item.canUpload = canUpload;
|
|
|
|
item.error = error;
|
|
|
|
|
|
|
|
// get video thumbnails
|
|
|
|
if (isAndroid && this.files.length > 1 && item.mime?.match?.(/video/)) {
|
|
|
|
try {
|
|
|
|
const VideoThumbnails = require('expo-video-thumbnails');
|
|
|
|
const { uri } = await VideoThumbnails.getThumbnailAsync(item.path);
|
|
|
|
item.uri = uri;
|
|
|
|
} catch {
|
|
|
|
// Do nothing
|
|
|
|
}
|
2020-06-26 20:22:56 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
// Set a filename, if there isn't any
|
|
|
|
if (!item.filename) {
|
2022-04-11 18:17:28 +00:00
|
|
|
item.filename = `${new Date().toISOString()}.jpg`;
|
2021-09-13 20:41:05 +00:00
|
|
|
}
|
|
|
|
return item;
|
|
|
|
})
|
|
|
|
);
|
2020-06-26 20:22:56 +00:00
|
|
|
return {
|
|
|
|
attachments: items,
|
|
|
|
selected: items[0]
|
|
|
|
};
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
send = async () => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { loading, selected } = this.state;
|
2019-12-18 19:31:41 +00:00
|
|
|
if (loading) {
|
|
|
|
return;
|
|
|
|
}
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
// update state
|
|
|
|
await this.selectFile(selected);
|
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
const { attachments, room, text, thread } = this.state;
|
2024-01-25 14:11:07 +00:00
|
|
|
const { navigation, server, user, route } = this.props;
|
|
|
|
|
|
|
|
const action = route.params?.action;
|
|
|
|
const selectedMessages = route.params?.selectedMessages ?? [];
|
2020-06-26 20:22:56 +00:00
|
|
|
|
|
|
|
// if it's share extension this should show loading
|
|
|
|
if (this.isShareExtension) {
|
|
|
|
this.setState({ loading: true });
|
2022-08-19 21:14:37 +00:00
|
|
|
sendLoadingEvent({ visible: true });
|
2020-06-26 20:22:56 +00:00
|
|
|
|
2021-09-13 20:41:05 +00:00
|
|
|
// if it's not share extension this can close
|
2019-07-18 17:44:02 +00:00
|
|
|
} else {
|
2020-06-26 20:22:56 +00:00
|
|
|
navigation.pop();
|
2019-07-18 17:44:02 +00:00
|
|
|
}
|
|
|
|
|
2023-01-05 18:23:11 +00:00
|
|
|
let msg: string | undefined;
|
2024-01-25 14:11:07 +00:00
|
|
|
if (action === 'quote') {
|
|
|
|
msg = await prepareQuoteMessage('', selectedMessages);
|
2023-01-05 18:23:11 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
try {
|
|
|
|
// Send attachment
|
|
|
|
if (attachments.length) {
|
2021-09-13 20:41:05 +00:00
|
|
|
await Promise.all(
|
|
|
|
attachments.map(({ filename: name, mime: type, description, size, path, canUpload }) => {
|
|
|
|
if (canUpload) {
|
2022-04-28 20:37:25 +00:00
|
|
|
return sendFileMessage(
|
2021-09-13 20:41:05 +00:00
|
|
|
room.rid,
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
description,
|
|
|
|
size,
|
|
|
|
type,
|
|
|
|
path,
|
2023-01-05 18:23:11 +00:00
|
|
|
store: 'Uploads',
|
|
|
|
msg
|
2021-09-13 20:41:05 +00:00
|
|
|
},
|
|
|
|
thread?.id,
|
|
|
|
server,
|
|
|
|
{ id: user.id, token: user.token }
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return Promise.resolve();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
// Send text message
|
2020-06-26 20:22:56 +00:00
|
|
|
} else if (text.length) {
|
2022-04-28 20:37:25 +00:00
|
|
|
await sendMessage(room.rid, text, thread?.id, { id: user.id, token: user.token } as IUser);
|
2019-07-18 17:44:02 +00:00
|
|
|
}
|
2020-06-26 20:22:56 +00:00
|
|
|
} catch {
|
|
|
|
// Do nothing
|
2019-07-18 17:44:02 +00:00
|
|
|
}
|
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
// if it's share extension this should close
|
|
|
|
if (this.isShareExtension) {
|
2022-08-19 21:14:37 +00:00
|
|
|
sendLoadingEvent({ visible: false });
|
2020-06-26 20:22:56 +00:00
|
|
|
ShareExtension.close();
|
2019-07-18 17:44:02 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-05-11 17:59:29 +00:00
|
|
|
selectFile = (item: IShareAttachment) => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { attachments, selected } = this.state;
|
|
|
|
if (attachments.length > 0) {
|
2024-01-25 14:11:07 +00:00
|
|
|
const text = this.messageComposerRef.current?.getText();
|
2021-09-13 20:41:05 +00:00
|
|
|
const newAttachments = attachments.map(att => {
|
2020-06-26 20:22:56 +00:00
|
|
|
if (att.path === selected.path) {
|
|
|
|
att.description = text;
|
|
|
|
}
|
|
|
|
return att;
|
|
|
|
});
|
2024-01-25 14:11:07 +00:00
|
|
|
this.setState({ attachments: newAttachments, selected: item });
|
|
|
|
this.messageComposerRef.current?.setInput(item.description || '');
|
2020-06-26 20:22:56 +00:00
|
|
|
}
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2022-05-11 17:59:29 +00:00
|
|
|
removeFile = (item: IShareAttachment) => {
|
2020-06-26 20:22:56 +00:00
|
|
|
const { selected, attachments } = this.state;
|
2024-01-25 14:11:07 +00:00
|
|
|
let newSelected = selected;
|
2020-06-26 20:22:56 +00:00
|
|
|
if (item.path === selected.path) {
|
|
|
|
const selectedIndex = attachments.findIndex(att => att.path === selected.path);
|
|
|
|
// Selects the next one, if available
|
|
|
|
if (attachments[selectedIndex + 1]?.path) {
|
|
|
|
newSelected = attachments[selectedIndex + 1];
|
2021-09-13 20:41:05 +00:00
|
|
|
// If it's the last thumb, selects the previous one
|
2020-06-26 20:22:56 +00:00
|
|
|
} else {
|
|
|
|
newSelected = attachments[selectedIndex - 1] || {};
|
|
|
|
}
|
|
|
|
}
|
2024-01-25 14:11:07 +00:00
|
|
|
this.setState({ attachments: attachments.filter(att => att.path !== item.path), selected: newSelected ?? selected });
|
|
|
|
this.messageComposerRef.current?.setInput(newSelected.description || '');
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2021-11-16 16:19:50 +00:00
|
|
|
onChangeText = (text: string) => {
|
2020-06-26 20:22:56 +00:00
|
|
|
this.setState({ text });
|
2021-09-13 20:41:05 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
2020-06-26 20:22:56 +00:00
|
|
|
renderContent = () => {
|
2024-01-25 14:11:07 +00:00
|
|
|
const { attachments, selected, text, room, thread } = this.state;
|
|
|
|
const { theme, route } = this.props;
|
2020-06-26 20:22:56 +00:00
|
|
|
|
|
|
|
if (attachments.length) {
|
|
|
|
return (
|
2024-01-25 14:11:07 +00:00
|
|
|
<RoomContext.Provider
|
|
|
|
value={{
|
|
|
|
rid: room.rid,
|
|
|
|
t: room.t,
|
|
|
|
tmid: thread.id,
|
|
|
|
sharing: true,
|
|
|
|
action: route.params?.action,
|
|
|
|
selectedMessages: route.params?.selectedMessages,
|
|
|
|
onSendMessage: this.send
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<View style={styles.container}>
|
|
|
|
<Preview
|
|
|
|
// using key just to reset zoom/move after change selected
|
|
|
|
key={selected?.path}
|
|
|
|
item={selected}
|
|
|
|
length={attachments.length}
|
2023-08-18 17:48:33 +00:00
|
|
|
theme={theme}
|
2020-06-26 20:22:56 +00:00
|
|
|
isShareExtension={this.isShareExtension}
|
|
|
|
/>
|
2024-01-25 14:11:07 +00:00
|
|
|
<MessageComposerContainer ref={this.messageComposerRef}>
|
|
|
|
<Thumbs
|
|
|
|
attachments={attachments}
|
|
|
|
theme={theme}
|
|
|
|
isShareExtension={this.isShareExtension}
|
|
|
|
onPress={this.selectFile}
|
|
|
|
onRemove={this.removeFile}
|
|
|
|
/>
|
|
|
|
</MessageComposerContainer>
|
|
|
|
</View>
|
|
|
|
</RoomContext.Provider>
|
2020-06-26 20:22:56 +00:00
|
|
|
);
|
|
|
|
}
|
2019-07-18 17:44:02 +00:00
|
|
|
|
|
|
|
return (
|
2022-05-18 19:17:42 +00:00
|
|
|
<FormTextInput
|
2020-06-26 20:22:56 +00:00
|
|
|
containerStyle={styles.inputContainer}
|
2023-08-18 17:48:33 +00:00
|
|
|
inputStyle={[styles.input, styles.textInput, { backgroundColor: themes[theme].focusedBackground }]}
|
2019-07-18 17:44:02 +00:00
|
|
|
placeholder=''
|
2020-06-26 20:22:56 +00:00
|
|
|
onChangeText={this.onChangeText}
|
|
|
|
defaultValue=''
|
2019-07-18 17:44:02 +00:00
|
|
|
multiline
|
|
|
|
textAlignVertical='top'
|
|
|
|
autoFocus
|
2020-06-26 20:22:56 +00:00
|
|
|
value={text}
|
2019-07-18 17:44:02 +00:00
|
|
|
/>
|
|
|
|
);
|
2020-06-26 20:22:56 +00:00
|
|
|
};
|
2019-07-18 17:44:02 +00:00
|
|
|
|
|
|
|
render() {
|
2021-09-13 20:41:05 +00:00
|
|
|
console.count(`${this.constructor.name}.render calls`);
|
2022-08-19 21:14:37 +00:00
|
|
|
const { readOnly, room } = this.state;
|
2020-04-13 12:51:16 +00:00
|
|
|
const { theme } = this.props;
|
|
|
|
if (readOnly || isBlocked(room)) {
|
2020-06-26 20:22:56 +00:00
|
|
|
return (
|
2023-08-18 17:48:33 +00:00
|
|
|
<View style={[styles.container, styles.centered, { backgroundColor: themes[theme].backgroundColor }]}>
|
|
|
|
<Text style={[styles.title, { color: themes[theme].titleText }]}>
|
2020-06-26 20:22:56 +00:00
|
|
|
{isBlocked(room) ? I18n.t('This_room_is_blocked') : I18n.t('This_room_is_read_only')}
|
2019-07-18 17:44:02 +00:00
|
|
|
</Text>
|
|
|
|
</View>
|
2020-06-26 20:22:56 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return (
|
2023-08-18 17:48:33 +00:00
|
|
|
<SafeAreaView style={{ backgroundColor: themes[theme].backgroundColor }}>
|
|
|
|
<StatusBar barStyle='light-content' backgroundColor={themes[theme].previewBackground} />
|
2020-06-26 20:22:56 +00:00
|
|
|
{this.renderContent()}
|
|
|
|
</SafeAreaView>
|
2019-07-18 17:44:02 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2022-05-11 17:59:29 +00:00
|
|
|
const mapStateToProps = (state: IApplicationState) => ({
|
2020-06-26 20:22:56 +00:00
|
|
|
user: getUserSelector(state),
|
2020-11-04 16:53:44 +00:00
|
|
|
server: state.share.server.server || state.server.server,
|
2022-05-11 17:59:29 +00:00
|
|
|
FileUpload_MediaTypeWhiteList: state.settings.FileUpload_MediaTypeWhiteList as string,
|
|
|
|
FileUpload_MaxFileSize: state.settings.FileUpload_MaxFileSize as number
|
2020-06-26 20:22:56 +00:00
|
|
|
});
|
2019-08-07 13:51:34 +00:00
|
|
|
|
2019-12-04 16:39:53 +00:00
|
|
|
export default connect(mapStateToProps)(withTheme(ShareView));
|