2017-08-04 00:34:37 +00:00
|
|
|
import React from 'react';
|
2017-08-05 18:16:32 +00:00
|
|
|
import PropTypes from 'prop-types';
|
2018-09-25 19:28:42 +00:00
|
|
|
import {
|
2018-10-29 13:54:23 +00:00
|
|
|
Text, View, LayoutAnimation, ActivityIndicator, Platform
|
2018-09-25 19:28:42 +00:00
|
|
|
} from 'react-native';
|
2018-09-26 13:56:36 +00:00
|
|
|
import { connect, Provider } from 'react-redux';
|
2018-11-14 21:42:03 +00:00
|
|
|
import { RectButton, gestureHandlerRootHOC } from 'react-native-gesture-handler';
|
2018-09-26 13:56:36 +00:00
|
|
|
import { Navigation } from 'react-native-navigation';
|
2018-10-23 21:39:48 +00:00
|
|
|
import SafeAreaView from 'react-native-safe-area-view';
|
2017-08-13 01:35:09 +00:00
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
import { openRoom as openRoomAction, closeRoom as closeRoomAction, setLastOpen as setLastOpenAction } from '../../actions/room';
|
|
|
|
import { toggleReactionPicker as toggleReactionPickerAction, actionsShow as actionsShowAction } from '../../actions/messages';
|
2018-04-03 16:24:59 +00:00
|
|
|
import LoggedView from '../View';
|
2018-01-30 19:48:26 +00:00
|
|
|
import { List } from './ListView';
|
2017-12-27 15:22:06 +00:00
|
|
|
import database from '../../lib/realm';
|
2017-12-08 19:13:21 +00:00
|
|
|
import RocketChat from '../../lib/rocketchat';
|
|
|
|
import Message from '../../containers/message';
|
|
|
|
import MessageActions from '../../containers/MessageActions';
|
2017-12-13 15:00:26 +00:00
|
|
|
import MessageErrorActions from '../../containers/MessageErrorActions';
|
2017-12-08 19:13:21 +00:00
|
|
|
import MessageBox from '../../containers/MessageBox';
|
2018-01-30 19:48:26 +00:00
|
|
|
import ReactionPicker from './ReactionPicker';
|
2018-07-17 19:10:27 +00:00
|
|
|
import UploadProgress from './UploadProgress';
|
2017-12-08 19:13:21 +00:00
|
|
|
import styles from './styles';
|
2018-05-18 17:55:08 +00:00
|
|
|
import log from '../../utils/log';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../../i18n';
|
2018-07-10 13:40:32 +00:00
|
|
|
import { iconsMap } from '../../Icons';
|
2018-09-26 13:56:36 +00:00
|
|
|
import store from '../../lib/createStore';
|
2018-10-02 12:33:21 +00:00
|
|
|
import ConnectionBadge from '../../containers/ConnectionBadge';
|
2018-11-14 21:42:03 +00:00
|
|
|
import { DEFAULT_HEADER } from '../../constants/headerOptions';
|
2018-09-26 13:56:36 +00:00
|
|
|
|
|
|
|
let RoomActionsView = null;
|
2017-08-14 14:15:37 +00:00
|
|
|
|
2018-07-10 13:40:32 +00:00
|
|
|
@connect(state => ({
|
|
|
|
user: {
|
|
|
|
id: state.login.user && state.login.user.id,
|
|
|
|
username: state.login.user && state.login.user.username,
|
|
|
|
token: state.login.user && state.login.user.token
|
|
|
|
},
|
|
|
|
actionMessage: state.messages.actionMessage,
|
|
|
|
showActions: state.messages.showActions,
|
2018-12-05 20:52:08 +00:00
|
|
|
showErrorActions: state.messages.showErrorActions,
|
|
|
|
appState: state.app.ready && state.app.foreground ? 'foreground' : 'background'
|
2018-07-10 13:40:32 +00:00
|
|
|
}), dispatch => ({
|
2018-09-25 19:28:42 +00:00
|
|
|
openRoom: room => dispatch(openRoomAction(room)),
|
|
|
|
setLastOpen: date => dispatch(setLastOpenAction(date)),
|
|
|
|
toggleReactionPicker: message => dispatch(toggleReactionPickerAction(message)),
|
|
|
|
actionsShow: actionMessage => dispatch(actionsShowAction(actionMessage)),
|
|
|
|
closeRoom: () => dispatch(closeRoomAction())
|
2018-07-10 13:40:32 +00:00
|
|
|
}))
|
|
|
|
/** @extends React.Component */
|
2018-04-03 16:24:59 +00:00
|
|
|
export default class RoomView extends LoggedView {
|
2018-10-23 21:39:48 +00:00
|
|
|
static options() {
|
|
|
|
return {
|
2018-11-14 21:42:03 +00:00
|
|
|
...DEFAULT_HEADER,
|
2018-10-23 21:39:48 +00:00
|
|
|
topBar: {
|
2018-11-14 21:42:03 +00:00
|
|
|
...DEFAULT_HEADER.topBar,
|
2018-10-31 18:40:08 +00:00
|
|
|
title: {
|
|
|
|
component: {
|
|
|
|
name: 'RoomHeaderView',
|
2018-11-14 21:42:03 +00:00
|
|
|
alignment: 'left'
|
2018-10-31 18:40:08 +00:00
|
|
|
}
|
|
|
|
},
|
2018-10-23 21:39:48 +00:00
|
|
|
rightButtons: [{
|
|
|
|
id: 'more',
|
|
|
|
testID: 'room-view-header-actions',
|
|
|
|
icon: iconsMap.more
|
|
|
|
}, {
|
|
|
|
id: 'star',
|
|
|
|
testID: 'room-view-header-star',
|
|
|
|
icon: iconsMap.starOutline
|
|
|
|
}]
|
2018-11-05 19:02:54 +00:00
|
|
|
},
|
|
|
|
blurOnUnmount: true
|
2018-10-23 21:39:48 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-08-05 18:16:32 +00:00
|
|
|
static propTypes = {
|
2018-10-23 21:39:48 +00:00
|
|
|
componentId: PropTypes.string,
|
2017-11-20 22:18:00 +00:00
|
|
|
openRoom: PropTypes.func.isRequired,
|
2018-01-16 20:27:57 +00:00
|
|
|
setLastOpen: PropTypes.func.isRequired,
|
2018-07-10 13:40:32 +00:00
|
|
|
user: PropTypes.shape({
|
|
|
|
id: PropTypes.string.isRequired,
|
|
|
|
username: PropTypes.string.isRequired,
|
|
|
|
token: PropTypes.string.isRequired
|
|
|
|
}),
|
2017-08-12 20:52:55 +00:00
|
|
|
rid: PropTypes.string,
|
2018-12-21 10:55:35 +00:00
|
|
|
name: PropTypes.string,
|
|
|
|
t: PropTypes.string,
|
2018-07-10 13:40:32 +00:00
|
|
|
showActions: PropTypes.bool,
|
|
|
|
showErrorActions: PropTypes.bool,
|
2018-01-30 19:48:26 +00:00
|
|
|
actionMessage: PropTypes.object,
|
2018-12-05 20:52:08 +00:00
|
|
|
appState: PropTypes.string,
|
2018-02-19 21:19:39 +00:00
|
|
|
toggleReactionPicker: PropTypes.func.isRequired,
|
2018-07-10 13:40:32 +00:00
|
|
|
actionsShow: PropTypes.func,
|
2018-09-25 19:28:42 +00:00
|
|
|
closeRoom: PropTypes.func
|
2017-09-25 13:15:28 +00:00
|
|
|
};
|
2017-08-05 18:16:32 +00:00
|
|
|
|
2017-08-04 00:34:37 +00:00
|
|
|
constructor(props) {
|
2018-04-03 16:24:59 +00:00
|
|
|
super('RoomView', props);
|
2018-09-25 19:28:42 +00:00
|
|
|
this.rid = props.rid;
|
2018-01-17 16:42:30 +00:00
|
|
|
this.rooms = database.objects('subscriptions').filtered('rid = $0', this.rid);
|
2017-08-07 18:42:02 +00:00
|
|
|
this.state = {
|
2018-07-18 20:34:59 +00:00
|
|
|
loaded: false,
|
2018-09-19 14:18:32 +00:00
|
|
|
joined: this.rooms.length > 0,
|
2018-12-21 10:55:35 +00:00
|
|
|
room: {}
|
2017-08-07 18:42:02 +00:00
|
|
|
};
|
2018-12-21 10:55:35 +00:00
|
|
|
this.focused = true;
|
2018-01-30 19:48:26 +00:00
|
|
|
this.onReactionPress = this.onReactionPress.bind(this);
|
2018-10-23 21:39:48 +00:00
|
|
|
Navigation.events().bindComponent(this);
|
2017-08-07 00:34:35 +00:00
|
|
|
}
|
2017-08-04 00:34:37 +00:00
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
componentDidMount() {
|
2018-12-05 20:52:08 +00:00
|
|
|
if (this.rooms.length === 0 && this.rid) {
|
2018-12-21 10:55:35 +00:00
|
|
|
const { rid, name, t } = this.props;
|
|
|
|
this.setState(
|
|
|
|
{ room: { rid, name, t } },
|
|
|
|
() => this.updateRoom()
|
|
|
|
);
|
2018-12-05 20:52:08 +00:00
|
|
|
}
|
2018-01-17 16:42:30 +00:00
|
|
|
this.rooms.addListener(this.updateRoom);
|
2018-10-23 21:39:48 +00:00
|
|
|
this.internalSetState({ loaded: true });
|
2018-02-08 14:08:50 +00:00
|
|
|
}
|
2018-09-19 14:18:32 +00:00
|
|
|
|
2018-01-09 17:12:55 +00:00
|
|
|
shouldComponentUpdate(nextProps, nextState) {
|
2018-09-26 13:56:36 +00:00
|
|
|
const {
|
2018-12-21 10:55:35 +00:00
|
|
|
room, loaded, joined
|
2018-09-26 13:56:36 +00:00
|
|
|
} = this.state;
|
2018-12-05 20:52:08 +00:00
|
|
|
const { showActions, showErrorActions, appState } = this.props;
|
2018-09-26 13:56:36 +00:00
|
|
|
|
|
|
|
if (room.ro !== nextState.room.ro) {
|
|
|
|
return true;
|
2018-10-23 21:39:48 +00:00
|
|
|
} else if (room.f !== nextState.room.f) {
|
|
|
|
return true;
|
2018-12-12 15:15:10 +00:00
|
|
|
} else if (room.blocked !== nextState.room.blocked) {
|
|
|
|
return true;
|
|
|
|
} else if (room.blocker !== nextState.room.blocker) {
|
|
|
|
return true;
|
|
|
|
} else if (room.archived !== nextState.room.archived) {
|
|
|
|
return true;
|
2018-09-26 13:56:36 +00:00
|
|
|
} else if (loaded !== nextState.loaded) {
|
|
|
|
return true;
|
|
|
|
} else if (joined !== nextState.joined) {
|
|
|
|
return true;
|
|
|
|
} else if (showActions !== nextProps.showActions) {
|
|
|
|
return true;
|
2018-11-16 11:06:29 +00:00
|
|
|
} else if (showErrorActions !== nextProps.showErrorActions) {
|
|
|
|
return true;
|
2018-12-05 20:52:08 +00:00
|
|
|
} else if (appState !== nextProps.appState) {
|
|
|
|
return true;
|
2018-09-26 13:56:36 +00:00
|
|
|
}
|
|
|
|
return false;
|
2017-09-21 17:08:00 +00:00
|
|
|
}
|
2018-07-10 13:40:32 +00:00
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState) {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { room } = this.state;
|
2018-12-05 20:52:08 +00:00
|
|
|
const { componentId, appState } = this.props;
|
2018-09-25 19:28:42 +00:00
|
|
|
|
|
|
|
if (prevState.room.f !== room.f) {
|
2018-12-12 15:15:10 +00:00
|
|
|
const rightButtons = [{
|
|
|
|
id: 'star',
|
|
|
|
testID: 'room-view-header-star',
|
|
|
|
icon: room.f ? iconsMap.star : iconsMap.starOutline
|
|
|
|
}];
|
|
|
|
if (room.t !== 'l') {
|
|
|
|
rightButtons.unshift({
|
|
|
|
id: 'more',
|
|
|
|
testID: 'room-view-header-actions',
|
|
|
|
icon: iconsMap.more
|
|
|
|
});
|
|
|
|
}
|
2018-10-23 21:39:48 +00:00
|
|
|
Navigation.mergeOptions(componentId, {
|
|
|
|
topBar: {
|
2018-12-12 15:15:10 +00:00
|
|
|
rightButtons
|
2018-10-23 21:39:48 +00:00
|
|
|
}
|
2018-07-10 13:40:32 +00:00
|
|
|
});
|
2018-12-05 20:52:08 +00:00
|
|
|
} else if (appState === 'foreground' && appState !== prevProps.appState) {
|
|
|
|
RocketChat.loadMissedMessages(room).catch(e => console.log(e));
|
|
|
|
RocketChat.readMessages(room.rid).catch(e => console.log(e));
|
2018-07-10 13:40:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-07 00:34:35 +00:00
|
|
|
componentWillUnmount() {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { closeRoom } = this.props;
|
|
|
|
closeRoom();
|
2018-12-21 10:55:35 +00:00
|
|
|
this.rooms.removeAllListeners();
|
2017-08-04 00:34:37 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
// eslint-disable-next-line
|
|
|
|
componentDidAppear() {
|
|
|
|
this.focused = true;
|
|
|
|
}
|
2018-12-05 20:52:08 +00:00
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
// eslint-disable-next-line
|
|
|
|
componentDidDisappear() {
|
|
|
|
this.focused = false;
|
2018-12-05 20:52:08 +00:00
|
|
|
}
|
2018-01-30 19:48:26 +00:00
|
|
|
|
2018-02-19 21:19:39 +00:00
|
|
|
onMessageLongPress = (message) => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { actionsShow } = this.props;
|
|
|
|
actionsShow(message);
|
2018-02-19 21:19:39 +00:00
|
|
|
}
|
|
|
|
|
2018-01-30 19:48:26 +00:00
|
|
|
onReactionPress = (shortname, messageId) => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { actionMessage, toggleReactionPicker } = this.props;
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
|
|
|
if (!messageId) {
|
2018-09-25 19:28:42 +00:00
|
|
|
RocketChat.setReaction(shortname, actionMessage._id);
|
|
|
|
return toggleReactionPicker();
|
2018-05-18 17:55:08 +00:00
|
|
|
}
|
|
|
|
RocketChat.setReaction(shortname, messageId);
|
|
|
|
} catch (e) {
|
|
|
|
log('RoomView.onReactionPress', e);
|
2018-01-30 19:48:26 +00:00
|
|
|
}
|
|
|
|
};
|
2017-08-04 00:34:37 +00:00
|
|
|
|
2018-10-23 21:39:48 +00:00
|
|
|
internalSetState = (...args) => {
|
2018-10-29 13:54:23 +00:00
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
LayoutAnimation.easeInEaseOut();
|
|
|
|
}
|
2018-10-23 21:39:48 +00:00
|
|
|
this.setState(...args);
|
|
|
|
}
|
|
|
|
|
|
|
|
navigationButtonPressed = ({ buttonId }) => {
|
|
|
|
const { room } = this.state;
|
|
|
|
const { rid, f } = room;
|
|
|
|
const { componentId } = this.props;
|
|
|
|
|
|
|
|
if (buttonId === 'more') {
|
|
|
|
if (RoomActionsView == null) {
|
|
|
|
RoomActionsView = require('../RoomActionsView').default;
|
2018-11-14 21:42:03 +00:00
|
|
|
Navigation.registerComponentWithRedux('RoomActionsView', () => gestureHandlerRootHOC(RoomActionsView), Provider, store);
|
2018-10-23 21:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Navigation.push(componentId, {
|
|
|
|
component: {
|
|
|
|
id: 'RoomActionsView',
|
|
|
|
name: 'RoomActionsView',
|
|
|
|
passProps: {
|
|
|
|
rid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (buttonId === 'star') {
|
|
|
|
try {
|
2018-12-05 20:52:08 +00:00
|
|
|
RocketChat.toggleFavorite(rid, !f);
|
2018-10-23 21:39:48 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('toggleFavorite', e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
// eslint-disable-next-line react/sort-comp
|
2018-10-23 21:39:48 +00:00
|
|
|
updateRoom = () => {
|
2018-10-31 18:40:08 +00:00
|
|
|
const { openRoom, setLastOpen } = this.props;
|
2018-09-25 19:28:42 +00:00
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
if (!this.focused) {
|
|
|
|
return;
|
|
|
|
}
|
2018-05-07 20:43:26 +00:00
|
|
|
if (this.rooms.length > 0) {
|
2018-05-18 17:55:08 +00:00
|
|
|
const { room: prevRoom } = this.state;
|
2018-10-16 20:30:04 +00:00
|
|
|
const room = JSON.parse(JSON.stringify(this.rooms[0] || {}));
|
2018-10-23 21:39:48 +00:00
|
|
|
this.internalSetState({ room });
|
2018-07-18 20:34:59 +00:00
|
|
|
|
2018-12-21 10:55:35 +00:00
|
|
|
if (!prevRoom._id) {
|
2018-09-25 19:28:42 +00:00
|
|
|
openRoom({
|
2018-07-18 20:34:59 +00:00
|
|
|
...room
|
2018-05-18 17:55:08 +00:00
|
|
|
});
|
2018-07-18 20:34:59 +00:00
|
|
|
if (room.alert || room.unread || room.userMentions) {
|
2018-09-25 19:28:42 +00:00
|
|
|
setLastOpen(room.ls);
|
2018-05-18 17:55:08 +00:00
|
|
|
} else {
|
2018-09-25 19:28:42 +00:00
|
|
|
setLastOpen(null);
|
2018-05-18 17:55:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-19 14:18:32 +00:00
|
|
|
} else {
|
2018-12-05 20:52:08 +00:00
|
|
|
const { room } = this.state;
|
2018-12-21 10:55:35 +00:00
|
|
|
if (room.rid) {
|
|
|
|
openRoom(room);
|
|
|
|
this.internalSetState({ joined: false });
|
|
|
|
}
|
2018-05-07 20:43:26 +00:00
|
|
|
}
|
2018-01-17 16:42:30 +00:00
|
|
|
}
|
|
|
|
|
2018-02-08 14:08:50 +00:00
|
|
|
sendMessage = (message) => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { setLastOpen } = this.props;
|
2018-06-20 13:40:33 +00:00
|
|
|
LayoutAnimation.easeInEaseOut();
|
2018-02-08 14:08:50 +00:00
|
|
|
RocketChat.sendMessage(this.rid, message).then(() => {
|
2018-09-25 19:28:42 +00:00
|
|
|
setLastOpen(null);
|
2018-02-08 14:08:50 +00:00
|
|
|
});
|
|
|
|
};
|
2017-08-09 01:40:55 +00:00
|
|
|
|
2017-09-21 17:08:00 +00:00
|
|
|
joinRoom = async() => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { rid } = this.props;
|
2018-05-18 17:55:08 +00:00
|
|
|
try {
|
2018-12-05 20:52:08 +00:00
|
|
|
const result = await RocketChat.joinRoom(rid);
|
|
|
|
if (result.success) {
|
|
|
|
this.internalSetState({
|
|
|
|
joined: true
|
|
|
|
});
|
|
|
|
}
|
2018-05-18 17:55:08 +00:00
|
|
|
} catch (e) {
|
|
|
|
log('joinRoom', e);
|
|
|
|
}
|
2017-08-10 16:16:32 +00:00
|
|
|
};
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
isOwner = () => {
|
|
|
|
const { room } = this.state;
|
|
|
|
return room && room.roles && Array.from(Object.keys(room.roles), i => room.roles[i].value).includes('owner');
|
|
|
|
}
|
2018-05-24 20:17:45 +00:00
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
isMuted = () => {
|
|
|
|
const { room } = this.state;
|
|
|
|
const { user } = this.props;
|
|
|
|
return room && room.muted && Array.from(Object.keys(room.muted), i => room.muted[i].value).includes(user.username);
|
|
|
|
}
|
2018-05-24 20:17:45 +00:00
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
isReadOnly = () => {
|
|
|
|
const { room } = this.state;
|
|
|
|
return room.ro && this.isMuted() && !this.isOwner();
|
|
|
|
}
|
2018-05-24 20:17:45 +00:00
|
|
|
|
|
|
|
isBlocked = () => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { room } = this.state;
|
|
|
|
|
|
|
|
if (room) {
|
|
|
|
const { t, blocked, blocker } = room;
|
2018-05-24 20:17:45 +00:00
|
|
|
if (t === 'd' && (blocked || blocker)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
renderItem = (item, previousItem) => {
|
|
|
|
const { room } = this.state;
|
|
|
|
const { user } = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Message
|
|
|
|
key={item._id}
|
|
|
|
item={item}
|
|
|
|
status={item.status}
|
|
|
|
reactions={JSON.parse(JSON.stringify(item.reactions))}
|
|
|
|
user={user}
|
|
|
|
archived={room.archived}
|
|
|
|
broadcast={room.broadcast}
|
|
|
|
previousItem={previousItem}
|
|
|
|
_updatedAt={item._updatedAt}
|
|
|
|
onReactionPress={this.onReactionPress}
|
|
|
|
onLongPress={this.onMessageLongPress}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2017-08-07 00:34:35 +00:00
|
|
|
|
2017-08-10 16:16:32 +00:00
|
|
|
renderFooter = () => {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { joined, room } = this.state;
|
|
|
|
|
|
|
|
if (!joined) {
|
2018-09-19 14:18:32 +00:00
|
|
|
return (
|
2018-12-21 10:55:35 +00:00
|
|
|
<View style={styles.joinRoomContainer} key='room-view-join' testID='room-view-join'>
|
2018-09-19 14:18:32 +00:00
|
|
|
<Text style={styles.previewMode}>{I18n.t('You_are_in_preview_mode')}</Text>
|
|
|
|
<RectButton
|
|
|
|
onPress={this.joinRoom}
|
|
|
|
style={styles.joinRoomButton}
|
|
|
|
activeOpacity={0.5}
|
|
|
|
underlayColor='#fff'
|
|
|
|
>
|
2018-12-21 10:55:35 +00:00
|
|
|
<Text style={styles.joinRoomText} testID='room-view-join-button'>{I18n.t('Join')}</Text>
|
2018-09-19 14:18:32 +00:00
|
|
|
</RectButton>
|
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-09-25 19:28:42 +00:00
|
|
|
if (room.archived || this.isReadOnly()) {
|
2018-01-17 16:42:30 +00:00
|
|
|
return (
|
2018-12-12 15:15:10 +00:00
|
|
|
<View style={styles.readOnly} key='room-view-read-only'>
|
2018-06-01 17:38:13 +00:00
|
|
|
<Text>{I18n.t('This_room_is_read_only')}</Text>
|
2018-01-17 16:42:30 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-05-24 20:17:45 +00:00
|
|
|
if (this.isBlocked()) {
|
|
|
|
return (
|
2018-12-12 15:15:10 +00:00
|
|
|
<View style={styles.readOnly} key='room-view-block'>
|
2018-06-01 17:38:13 +00:00
|
|
|
<Text>{I18n.t('This_room_is_blocked')}</Text>
|
2018-05-24 20:17:45 +00:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
2018-08-10 17:26:36 +00:00
|
|
|
return <MessageBox key='room-view-messagebox' onSubmit={this.sendMessage} rid={this.rid} />;
|
2017-09-25 13:15:28 +00:00
|
|
|
};
|
2017-08-09 20:08:50 +00:00
|
|
|
|
2018-07-18 20:34:59 +00:00
|
|
|
renderList = () => {
|
2018-12-21 10:55:35 +00:00
|
|
|
const { loaded, room } = this.state;
|
|
|
|
if (!loaded || !room.rid) {
|
2018-07-18 20:34:59 +00:00
|
|
|
return <ActivityIndicator style={styles.loading} />;
|
|
|
|
}
|
|
|
|
return (
|
2018-08-10 17:26:36 +00:00
|
|
|
[
|
|
|
|
<List
|
|
|
|
key='room-view-messages'
|
2018-12-21 10:55:35 +00:00
|
|
|
room={room}
|
2018-08-10 17:26:36 +00:00
|
|
|
renderRow={this.renderItem}
|
|
|
|
/>,
|
|
|
|
this.renderFooter()
|
|
|
|
]
|
2018-07-18 20:34:59 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-08-04 00:34:37 +00:00
|
|
|
render() {
|
2018-09-25 19:28:42 +00:00
|
|
|
const { room } = this.state;
|
|
|
|
const { user, showActions, showErrorActions } = this.props;
|
|
|
|
|
2017-08-04 00:34:37 +00:00
|
|
|
return (
|
2018-10-23 21:39:48 +00:00
|
|
|
<SafeAreaView style={styles.container} testID='room-view' forceInset={{ bottom: 'never' }}>
|
2018-07-18 20:34:59 +00:00
|
|
|
{this.renderList()}
|
2018-09-25 19:28:42 +00:00
|
|
|
{room._id && showActions
|
|
|
|
? <MessageActions room={room} user={user} />
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
{showErrorActions ? <MessageErrorActions /> : null}
|
2018-01-30 19:48:26 +00:00
|
|
|
<ReactionPicker onEmojiSelected={this.onReactionPress} />
|
2018-07-17 19:10:27 +00:00
|
|
|
<UploadProgress rid={this.rid} />
|
2018-10-02 12:33:21 +00:00
|
|
|
<ConnectionBadge />
|
2018-08-01 19:35:06 +00:00
|
|
|
</SafeAreaView>
|
2017-08-04 00:34:37 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|