Use FlatList in RoomView (#762)
This commit is contained in:
parent
2ce770fd22
commit
fd5fbe47e8
File diff suppressed because it is too large
Load Diff
Binary file not shown.
After Width: | Height: | Size: 76 KiB |
|
@ -35,8 +35,7 @@ export const ROOM = createRequestTypes('ROOM', [
|
||||||
'LEAVE',
|
'LEAVE',
|
||||||
'ERASE',
|
'ERASE',
|
||||||
'USER_TYPING',
|
'USER_TYPING',
|
||||||
'MESSAGE_RECEIVED',
|
'MESSAGE_RECEIVED'
|
||||||
'SET_LAST_OPEN'
|
|
||||||
]);
|
]);
|
||||||
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT']);
|
export const APP = createRequestTypes('APP', ['START', 'READY', 'INIT']);
|
||||||
export const MESSAGES = createRequestTypes('MESSAGES', [
|
export const MESSAGES = createRequestTypes('MESSAGES', [
|
||||||
|
|
|
@ -64,10 +64,3 @@ export function roomMessageReceived(message) {
|
||||||
message
|
message
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setLastOpen(date = new Date()) {
|
|
||||||
return {
|
|
||||||
type: types.ROOM.SET_LAST_OPEN,
|
|
||||||
date
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { isIOS } from '../utils/deviceInfo';
|
||||||
export const COLOR_DANGER = '#f5455c';
|
export const COLOR_DANGER = '#f5455c';
|
||||||
export const COLOR_BUTTON_PRIMARY = '#1d74f5';
|
export const COLOR_BUTTON_PRIMARY = '#1d74f5';
|
||||||
export const COLOR_TEXT = '#292E35';
|
export const COLOR_TEXT = '#292E35';
|
||||||
export const COLOR_SEPARATOR = '#CBCED1';
|
export const COLOR_SEPARATOR = '#A7A7AA';
|
||||||
export const STATUS_COLORS = {
|
export const STATUS_COLORS = {
|
||||||
online: '#2de0a5',
|
online: '#2de0a5',
|
||||||
busy: COLOR_DANGER,
|
busy: COLOR_DANGER,
|
||||||
|
@ -11,6 +11,6 @@ export const STATUS_COLORS = {
|
||||||
offline: '#cbced1'
|
offline: '#cbced1'
|
||||||
};
|
};
|
||||||
|
|
||||||
export const HEADER_BACKGROUND = isIOS ? '#FFF' : '#2F343D';
|
export const HEADER_BACKGROUND = isIOS ? '#f8f8f8' : '#2F343D';
|
||||||
export const HEADER_TITLE = isIOS ? '#0C0D0F' : '#FFF';
|
export const HEADER_TITLE = isIOS ? '#0C0D0F' : '#FFF';
|
||||||
export const HEADER_BACK = isIOS ? '#1d74f5' : '#FFF';
|
export const HEADER_BACK = isIOS ? '#1d74f5' : '#FFF';
|
||||||
|
|
|
@ -365,7 +365,7 @@ export default class Message extends PureComponent {
|
||||||
onPress={this.onPress}
|
onPress={this.onPress}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
style={[styles.container, header && styles.marginBottom, editing && styles.editing, style]}
|
style={[styles.container, header && styles.marginTop, editing && styles.editing, style]}
|
||||||
accessibilityLabel={accessibilityLabel}
|
accessibilityLabel={accessibilityLabel}
|
||||||
>
|
>
|
||||||
<View style={styles.flex}>
|
<View style={styles.flex}>
|
||||||
|
|
|
@ -101,7 +101,6 @@ export default class MessageContainer extends React.Component {
|
||||||
return _updatedAt.toGMTString() !== nextProps._updatedAt.toGMTString();
|
return _updatedAt.toGMTString() !== nextProps._updatedAt.toGMTString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onLongPress = () => {
|
onLongPress = () => {
|
||||||
const { onLongPress } = this.props;
|
const { onLongPress } = this.props;
|
||||||
onLongPress(this.parseMessage());
|
onLongPress(this.parseMessage());
|
||||||
|
|
|
@ -5,11 +5,10 @@ export default StyleSheet.create({
|
||||||
flexDirection: 'row'
|
flexDirection: 'row'
|
||||||
},
|
},
|
||||||
container: {
|
container: {
|
||||||
paddingVertical: 5,
|
paddingVertical: 4,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
paddingHorizontal: 15,
|
paddingHorizontal: 14,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
transform: [{ scaleY: -1 }],
|
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
messageContent: {
|
messageContent: {
|
||||||
|
@ -39,8 +38,8 @@ export default StyleSheet.create({
|
||||||
height: 20
|
height: 20
|
||||||
},
|
},
|
||||||
temp: { opacity: 0.3 },
|
temp: { opacity: 0.3 },
|
||||||
marginBottom: {
|
marginTop: {
|
||||||
marginBottom: 10
|
marginTop: 10
|
||||||
},
|
},
|
||||||
reactionsContainer: {
|
reactionsContainer: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
|
@ -82,7 +81,7 @@ export default StyleSheet.create({
|
||||||
marginLeft: 7
|
marginLeft: 7
|
||||||
},
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
marginTop: 5
|
marginTop: 4
|
||||||
},
|
},
|
||||||
addReaction: {
|
addReaction: {
|
||||||
color: '#1D74F5'
|
color: '#1D74F5'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { AsyncStorage } from 'react-native';
|
import { AsyncStorage, InteractionManager } from 'react-native';
|
||||||
import foreach from 'lodash/forEach';
|
import foreach from 'lodash/forEach';
|
||||||
import semver from 'semver';
|
import semver from 'semver';
|
||||||
import { Rocketchat as RocketchatClient } from '@rocket.chat/sdk';
|
import { Rocketchat as RocketchatClient } from '@rocket.chat/sdk';
|
||||||
|
@ -118,17 +118,17 @@ const RocketChat = {
|
||||||
reduxStore.dispatch(setUser({ status: 'offline' }));
|
reduxStore.dispatch(setUser({ status: 'offline' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._setUserTimer) {
|
if (!this._setUserTimer) {
|
||||||
clearTimeout(this._setUserTimer);
|
this._setUserTimer = setTimeout(() => {
|
||||||
this._setUserTimer = null;
|
const batchUsers = this.activeUsers;
|
||||||
|
InteractionManager.runAfterInteractions(() => {
|
||||||
|
reduxStore.dispatch(setActiveUser(batchUsers));
|
||||||
|
});
|
||||||
|
this._setUserTimer = null;
|
||||||
|
return this.activeUsers = {};
|
||||||
|
}, 10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setUserTimer = setTimeout(() => {
|
|
||||||
reduxStore.dispatch(setActiveUser(this.activeUsers));
|
|
||||||
this._setUserTimer = null;
|
|
||||||
return this.activeUsers = {};
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
const activeUser = reduxStore.getState().activeUsers[ddpMessage.id];
|
const activeUser = reduxStore.getState().activeUsers[ddpMessage.id];
|
||||||
if (!ddpMessage.fields) {
|
if (!ddpMessage.fields) {
|
||||||
this.activeUsers[ddpMessage.id] = {};
|
this.activeUsers[ddpMessage.id] = {};
|
||||||
|
@ -145,11 +145,18 @@ const RocketChat = {
|
||||||
}
|
}
|
||||||
this.roomsSub = await this.subscribeRooms();
|
this.roomsSub = await this.subscribeRooms();
|
||||||
|
|
||||||
this.sdk.subscribe('activeUsers');
|
|
||||||
this.sdk.subscribe('roles');
|
this.sdk.subscribe('roles');
|
||||||
this.getPermissions();
|
this.getPermissions();
|
||||||
this.getCustomEmoji();
|
this.getCustomEmoji();
|
||||||
this.registerPushToken().catch(e => console.log(e));
|
this.registerPushToken().catch(e => console.log(e));
|
||||||
|
|
||||||
|
if (this.activeUsersSubTimeout) {
|
||||||
|
clearTimeout(this.activeUsersSubTimeout);
|
||||||
|
this.activeUsersSubTimeout = false;
|
||||||
|
}
|
||||||
|
this.activeUsersSubTimeout = setTimeout(() => {
|
||||||
|
this.sdk.subscribe('activeUsers');
|
||||||
|
}, 5000);
|
||||||
},
|
},
|
||||||
connect({ server, user }) {
|
connect({ server, user }) {
|
||||||
database.setActiveDB(server);
|
database.setActiveDB(server);
|
||||||
|
@ -330,6 +337,11 @@ const RocketChat = {
|
||||||
this.roomsSub.stop();
|
this.roomsSub.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.activeUsersSubTimeout) {
|
||||||
|
clearTimeout(this.activeUsersSubTimeout);
|
||||||
|
this.activeUsersSubTimeout = false;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.removePushToken();
|
await this.removePushToken();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
@ -214,7 +214,7 @@ export default class RoomItem extends React.Component {
|
||||||
|
|
||||||
formatDate = date => moment(date).calendar(null, {
|
formatDate = date => moment(date).calendar(null, {
|
||||||
lastDay: `[${ I18n.t('Yesterday') }]`,
|
lastDay: `[${ I18n.t('Yesterday') }]`,
|
||||||
sameDay: 'h:mm A',
|
sameDay: 'HH:mm',
|
||||||
lastWeek: 'dddd',
|
lastWeek: 'dddd',
|
||||||
sameElse: 'MMM D'
|
sameElse: 'MMM D'
|
||||||
})
|
})
|
||||||
|
|
|
@ -9,18 +9,12 @@ export default function room(state = initialState, action) {
|
||||||
case types.ROOM.OPEN:
|
case types.ROOM.OPEN:
|
||||||
return {
|
return {
|
||||||
...initialState,
|
...initialState,
|
||||||
...action.room,
|
...action.room
|
||||||
lastOpen: new Date()
|
|
||||||
};
|
};
|
||||||
case types.ROOM.CLOSE:
|
case types.ROOM.CLOSE:
|
||||||
return {
|
return {
|
||||||
...initialState
|
...initialState
|
||||||
};
|
};
|
||||||
case types.ROOM.SET_LAST_OPEN:
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
lastOpen: action.date
|
|
||||||
};
|
|
||||||
case types.ROOM.ADD_USER_TYPING:
|
case types.ROOM.ADD_USER_TYPING:
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
|
|
|
@ -13,6 +13,7 @@ import I18n from '../i18n';
|
||||||
import DisclosureIndicator from '../containers/DisclosureIndicator';
|
import DisclosureIndicator from '../containers/DisclosureIndicator';
|
||||||
import { CloseModalButton } from '../containers/HeaderButton';
|
import { CloseModalButton } from '../containers/HeaderButton';
|
||||||
import StatusBar from '../containers/StatusBar';
|
import StatusBar from '../containers/StatusBar';
|
||||||
|
import { COLOR_SEPARATOR } from '../constants/colors';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -22,12 +23,12 @@ const styles = StyleSheet.create({
|
||||||
scroll: {
|
scroll: {
|
||||||
marginTop: 35,
|
marginTop: 35,
|
||||||
backgroundColor: '#fff',
|
backgroundColor: '#fff',
|
||||||
borderColor: '#cbced1',
|
borderColor: COLOR_SEPARATOR,
|
||||||
borderTopWidth: StyleSheet.hairlineWidth,
|
borderTopWidth: StyleSheet.hairlineWidth,
|
||||||
borderBottomWidth: StyleSheet.hairlineWidth
|
borderBottomWidth: StyleSheet.hairlineWidth
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
backgroundColor: '#cbced1',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
width: '100%',
|
width: '100%',
|
||||||
marginLeft: 20
|
marginLeft: 20
|
||||||
|
|
|
@ -17,6 +17,7 @@ import Button from '../containers/Button';
|
||||||
import I18n from '../i18n';
|
import I18n from '../i18n';
|
||||||
import { LegalButton } from '../containers/HeaderButton';
|
import { LegalButton } from '../containers/HeaderButton';
|
||||||
import StatusBar from '../containers/StatusBar';
|
import StatusBar from '../containers/StatusBar';
|
||||||
|
import { COLOR_SEPARATOR } from '../constants/colors';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -72,7 +73,7 @@ const styles = StyleSheet.create({
|
||||||
separatorLine: {
|
separatorLine: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
height: 1,
|
height: 1,
|
||||||
backgroundColor: '#e1e5e8'
|
backgroundColor: COLOR_SEPARATOR
|
||||||
},
|
},
|
||||||
separatorLineLeft: {
|
separatorLineLeft: {
|
||||||
marginRight: 15
|
marginRight: 15
|
||||||
|
|
|
@ -96,7 +96,7 @@ export default class LoginView extends LoggedView {
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
const { Site_Name, error } = this.props;
|
const { Site_Name, error } = this.props;
|
||||||
if (Site_Name && nextProps.Site_Name !== Site_Name) {
|
if (nextProps.Site_Name && nextProps.Site_Name !== Site_Name) {
|
||||||
this.setTitle(nextProps.Site_Name);
|
this.setTitle(nextProps.Site_Name);
|
||||||
} else if (nextProps.failure && !equal(error, nextProps.error)) {
|
} else if (nextProps.failure && !equal(error, nextProps.error)) {
|
||||||
if (nextProps.error && nextProps.error.error === 'totp-required') {
|
if (nextProps.error && nextProps.error.error === 'totp-required') {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -26,7 +27,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#ddd'
|
backgroundColor: COLOR_SEPARATOR
|
||||||
},
|
},
|
||||||
sectionSeparator: {
|
sectionSeparator: {
|
||||||
height: 10,
|
height: 10,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
|
||||||
import { COLOR_DANGER } from '../../constants/colors';
|
import { COLOR_DANGER, COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
buttonInverted: {
|
buttonInverted: {
|
||||||
|
@ -39,7 +39,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
divider: {
|
divider: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
borderColor: '#ddd',
|
borderColor: COLOR_SEPARATOR,
|
||||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
marginVertical: 20
|
marginVertical: 20
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
list: {
|
list: {
|
||||||
|
@ -24,7 +25,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#E1E5E8',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
marginLeft: 60
|
marginLeft: 60
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ImageBackground, StyleSheet } from 'react-native';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
image: {
|
||||||
|
width: '100%',
|
||||||
|
height: '100%',
|
||||||
|
position: 'absolute'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const EmptyRoom = React.memo(({ length }) => {
|
||||||
|
if (length === 0) {
|
||||||
|
return <ImageBackground source={{ uri: 'message_empty' }} style={styles.image} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
EmptyRoom.propTypes = {
|
||||||
|
length: PropTypes.number.isRequired
|
||||||
|
};
|
||||||
|
export default EmptyRoom;
|
|
@ -0,0 +1,50 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { StyleSheet } from 'react-native';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { STATUS_COLORS } from '../../../constants/colors';
|
||||||
|
import { CustomIcon } from '../../../lib/Icons';
|
||||||
|
import Status from '../../../containers/Status/Status';
|
||||||
|
import { isIOS } from '../../../utils/deviceInfo';
|
||||||
|
|
||||||
|
const ICON_SIZE = 18;
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
type: {
|
||||||
|
width: ICON_SIZE,
|
||||||
|
height: ICON_SIZE,
|
||||||
|
marginRight: 8,
|
||||||
|
color: isIOS ? '#9EA2A8' : '#fff'
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
marginRight: 8
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const Icon = React.memo(({ type, status }) => {
|
||||||
|
if (type === 'd') {
|
||||||
|
return <Status size={10} style={styles.status} status={status} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
const icon = type === 'c' ? 'hashtag' : 'lock';
|
||||||
|
return (
|
||||||
|
<CustomIcon
|
||||||
|
name={icon}
|
||||||
|
size={ICON_SIZE * 1}
|
||||||
|
style={[
|
||||||
|
styles.type,
|
||||||
|
{
|
||||||
|
width: ICON_SIZE * 1,
|
||||||
|
height: ICON_SIZE * 1
|
||||||
|
},
|
||||||
|
type === 'd' && { color: STATUS_COLORS[status] }
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
Icon.propTypes = {
|
||||||
|
type: PropTypes.string,
|
||||||
|
status: PropTypes.string
|
||||||
|
};
|
||||||
|
export default Icon;
|
|
@ -1,52 +1,45 @@
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import {
|
import {
|
||||||
View, Text, StyleSheet, LayoutAnimation, ScrollView
|
View, Text, StyleSheet, ScrollView
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { responsive } from 'react-native-responsive-ui';
|
import { responsive } from 'react-native-responsive-ui';
|
||||||
import equal from 'deep-equal';
|
import equal from 'deep-equal';
|
||||||
|
|
||||||
import I18n from '../../../i18n';
|
import I18n from '../../../i18n';
|
||||||
import { STATUS_COLORS } from '../../../constants/colors';
|
|
||||||
import sharedStyles from '../../Styles';
|
import sharedStyles from '../../Styles';
|
||||||
import { isIOS } from '../../../utils/deviceInfo';
|
import { isIOS } from '../../../utils/deviceInfo';
|
||||||
import { CustomIcon } from '../../../lib/Icons';
|
|
||||||
import Status from '../../../containers/Status/Status';
|
|
||||||
import { headerIconSize } from '../../../containers/HeaderButton';
|
import { headerIconSize } from '../../../containers/HeaderButton';
|
||||||
|
import Icon from './Icon';
|
||||||
|
|
||||||
const TITLE_SIZE = 18;
|
const TITLE_SIZE = 18;
|
||||||
const ICON_SIZE = 18;
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1
|
flex: 1,
|
||||||
|
height: '100%'
|
||||||
},
|
},
|
||||||
titleContainer: {
|
titleContainer: {
|
||||||
flexDirection: 'row',
|
flex: 1,
|
||||||
alignItems: 'center'
|
flexDirection: 'row'
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
...sharedStyles.textSemibold,
|
...sharedStyles.textSemibold,
|
||||||
color: isIOS ? '#0C0D0F' : '#fff',
|
color: isIOS ? '#0C0D0F' : '#fff',
|
||||||
fontSize: TITLE_SIZE
|
fontSize: TITLE_SIZE
|
||||||
},
|
},
|
||||||
type: {
|
scroll: {
|
||||||
width: ICON_SIZE,
|
alignItems: 'center'
|
||||||
height: ICON_SIZE,
|
|
||||||
marginRight: 8,
|
|
||||||
color: isIOS ? '#9EA2A8' : '#fff'
|
|
||||||
},
|
},
|
||||||
typing: {
|
typing: {
|
||||||
...sharedStyles.textRegular,
|
...sharedStyles.textRegular,
|
||||||
color: isIOS ? '#9EA2A8' : '#fff',
|
color: isIOS ? '#9EA2A8' : '#fff',
|
||||||
fontSize: 12
|
fontSize: 12,
|
||||||
|
marginBottom: 2
|
||||||
},
|
},
|
||||||
typingUsers: {
|
typingUsers: {
|
||||||
...sharedStyles.textSemibold,
|
...sharedStyles.textSemibold,
|
||||||
fontWeight: '600'
|
fontWeight: '600'
|
||||||
},
|
|
||||||
status: {
|
|
||||||
marginRight: 8
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,14 +112,14 @@ export default class RoomHeaderView extends Component {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate(prevProps) {
|
// componentDidUpdate(prevProps) {
|
||||||
if (isIOS) {
|
// if (isIOS) {
|
||||||
const { usersTyping } = this.props;
|
// const { usersTyping } = this.props;
|
||||||
if (!equal(prevProps.usersTyping, usersTyping)) {
|
// if (!equal(prevProps.usersTyping, usersTyping)) {
|
||||||
LayoutAnimation.easeInEaseOut();
|
// LayoutAnimation.easeInEaseOut();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
get typing() {
|
get typing() {
|
||||||
const { usersTyping } = this.props;
|
const { usersTyping } = this.props;
|
||||||
|
@ -146,32 +139,9 @@ export default class RoomHeaderView extends Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderIcon = () => {
|
|
||||||
const { type, status } = this.props;
|
|
||||||
if (type === 'd') {
|
|
||||||
return <Status size={10} style={styles.status} status={status} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
const icon = type === 'c' ? 'hashtag' : 'lock';
|
|
||||||
return (
|
|
||||||
<CustomIcon
|
|
||||||
name={icon}
|
|
||||||
size={ICON_SIZE * 1}
|
|
||||||
style={[
|
|
||||||
styles.type,
|
|
||||||
{
|
|
||||||
width: ICON_SIZE * 1,
|
|
||||||
height: ICON_SIZE * 1
|
|
||||||
},
|
|
||||||
type === 'd' && { color: STATUS_COLORS[status] }
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
window, title, usersTyping
|
window, title, usersTyping, type, status
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const portrait = window.height > window.width;
|
const portrait = window.height > window.width;
|
||||||
const widthScrollView = window.width - 6.5 * headerIconSize;
|
const widthScrollView = window.width - 6.5 * headerIconSize;
|
||||||
|
@ -190,8 +160,9 @@ export default class RoomHeaderView extends Component {
|
||||||
showsHorizontalScrollIndicator={false}
|
showsHorizontalScrollIndicator={false}
|
||||||
horizontal
|
horizontal
|
||||||
bounces={false}
|
bounces={false}
|
||||||
|
contentContainerStyle={styles.scroll}
|
||||||
>
|
>
|
||||||
{this.renderIcon()}
|
<Icon type={type} status={status} />
|
||||||
<Text style={[styles.title, { fontSize: TITLE_SIZE * scale }]} numberOfLines={1}>{title}</Text>
|
<Text style={[styles.title, { fontSize: TITLE_SIZE * scale }]} numberOfLines={1}>{title}</Text>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -0,0 +1,138 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { ActivityIndicator, FlatList } from 'react-native';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { responsive } from 'react-native-responsive-ui';
|
||||||
|
|
||||||
|
import styles from './styles';
|
||||||
|
import database from '../../lib/realm';
|
||||||
|
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
||||||
|
import debounce from '../../utils/debounce';
|
||||||
|
import RocketChat from '../../lib/rocketchat';
|
||||||
|
import log from '../../utils/log';
|
||||||
|
import EmptyRoom from './EmptyRoom';
|
||||||
|
import ScrollBottomButton from './ScrollBottomButton';
|
||||||
|
|
||||||
|
@responsive
|
||||||
|
export class List extends React.Component {
|
||||||
|
static propTypes = {
|
||||||
|
onEndReached: PropTypes.func,
|
||||||
|
renderFooter: PropTypes.func,
|
||||||
|
renderRow: PropTypes.func,
|
||||||
|
room: PropTypes.object,
|
||||||
|
window: PropTypes.object
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.data = database
|
||||||
|
.objects('messages')
|
||||||
|
.filtered('rid = $0', props.room.rid)
|
||||||
|
.sorted('ts', true);
|
||||||
|
this.state = {
|
||||||
|
loading: true,
|
||||||
|
loadingMore: false,
|
||||||
|
end: false,
|
||||||
|
messages: this.data.slice(),
|
||||||
|
showScollToBottomButton: false
|
||||||
|
};
|
||||||
|
this.data.addListener(this.updateState);
|
||||||
|
}
|
||||||
|
|
||||||
|
// shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
// const {
|
||||||
|
// loadingMore, loading, end, showScollToBottomButton, messages
|
||||||
|
// } = this.state;
|
||||||
|
// const { window } = this.props;
|
||||||
|
// return end !== nextState.end
|
||||||
|
// || loadingMore !== nextState.loadingMore
|
||||||
|
// || loading !== nextState.loading
|
||||||
|
// || showScollToBottomButton !== nextState.showScollToBottomButton
|
||||||
|
// // || messages.length !== nextState.messages.length
|
||||||
|
// || !equal(messages, nextState.messages)
|
||||||
|
// || window.width !== nextProps.window.width;
|
||||||
|
// }
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
this.data.removeAllListeners();
|
||||||
|
this.updateState.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line react/sort-comp
|
||||||
|
updateState = debounce(() => {
|
||||||
|
this.setState({ messages: this.data.slice(), loading: false, loadingMore: false });
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
onEndReached = async() => {
|
||||||
|
const {
|
||||||
|
loadingMore, loading, end, messages
|
||||||
|
} = this.state;
|
||||||
|
if (loadingMore || loading || end || messages.length < 50) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({ loadingMore: true });
|
||||||
|
const { room } = this.props;
|
||||||
|
try {
|
||||||
|
const result = await RocketChat.loadMessagesForRoom({ rid: room.rid, t: room.t, latest: this.data[this.data.length - 1].ts });
|
||||||
|
this.setState({ end: result.length < 50 });
|
||||||
|
} catch (e) {
|
||||||
|
this.setState({ loadingMore: false });
|
||||||
|
log('ListView.onEndReached', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scrollToBottom = () => {
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this.list.scrollToOffset({ offset: -100 });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleScroll = (event) => {
|
||||||
|
if (event.nativeEvent.contentOffset.y > 0) {
|
||||||
|
this.setState({ showScollToBottomButton: true });
|
||||||
|
} else {
|
||||||
|
this.setState({ showScollToBottomButton: false });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
renderFooter = () => {
|
||||||
|
const { loadingMore, loading } = this.state;
|
||||||
|
if (loadingMore || loading) {
|
||||||
|
return <ActivityIndicator style={styles.loadingMore} />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const { renderRow, window } = this.props;
|
||||||
|
const { showScollToBottomButton, messages } = this.state;
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<EmptyRoom length={messages.length} />
|
||||||
|
<FlatList
|
||||||
|
testID='room-view-messages'
|
||||||
|
ref={ref => this.list = ref}
|
||||||
|
keyExtractor={item => item._id}
|
||||||
|
data={messages}
|
||||||
|
extraData={this.state}
|
||||||
|
renderItem={({ item, index }) => renderRow(item, messages[index + 1])}
|
||||||
|
style={styles.list}
|
||||||
|
onScroll={this.handleScroll}
|
||||||
|
inverted
|
||||||
|
removeClippedSubviews
|
||||||
|
initialNumToRender={10}
|
||||||
|
onEndReached={this.onEndReached}
|
||||||
|
onEndReachedThreshold={0.5}
|
||||||
|
maxToRenderPerBatch={20}
|
||||||
|
ListFooterComponent={this.renderFooter}
|
||||||
|
{...scrollPersistTaps}
|
||||||
|
/>
|
||||||
|
<ScrollBottomButton
|
||||||
|
show={showScollToBottomButton}
|
||||||
|
onPress={this.scrollToBottom}
|
||||||
|
landscape={window.width > window.height}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,277 +0,0 @@
|
||||||
import { ListView as OldList } from 'realm/react-native';
|
|
||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
TouchableOpacity, ScrollView, ListView as OldList2, ImageBackground, ActivityIndicator
|
|
||||||
} from 'react-native';
|
|
||||||
import moment from 'moment';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import Separator from './Separator';
|
|
||||||
import styles from './styles';
|
|
||||||
import database from '../../lib/realm';
|
|
||||||
import scrollPersistTaps from '../../utils/scrollPersistTaps';
|
|
||||||
import debounce from '../../utils/debounce';
|
|
||||||
import RocketChat from '../../lib/rocketchat';
|
|
||||||
import log from '../../utils/log';
|
|
||||||
import { CustomIcon } from '../../lib/Icons';
|
|
||||||
import { isIOS, isNotch } from '../../utils/deviceInfo';
|
|
||||||
|
|
||||||
const DEFAULT_SCROLL_CALLBACK_THROTTLE = 100;
|
|
||||||
|
|
||||||
export class DataSource extends OldList.DataSource {
|
|
||||||
getRowData(sectionIndex: number, rowIndex: number): any {
|
|
||||||
const sectionID = this.sectionIdentities[sectionIndex];
|
|
||||||
const rowID = this.rowIdentities[sectionIndex][rowIndex];
|
|
||||||
return this._getRowData(this._dataBlob, sectionID, rowID);
|
|
||||||
}
|
|
||||||
_calculateDirtyArrays() { // eslint-disable-line
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const ds = new DataSource({ rowHasChanged: (r1, r2) => r1._id !== r2._id });
|
|
||||||
|
|
||||||
export class List extends React.Component {
|
|
||||||
static propTypes = {
|
|
||||||
onEndReached: PropTypes.func,
|
|
||||||
renderFooter: PropTypes.func,
|
|
||||||
renderRow: PropTypes.func,
|
|
||||||
room: PropTypes.object
|
|
||||||
};
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.data = database
|
|
||||||
.objects('messages')
|
|
||||||
.filtered('rid = $0', props.room.rid)
|
|
||||||
.sorted('ts', true);
|
|
||||||
this.state = {
|
|
||||||
loading: true,
|
|
||||||
loadingMore: false,
|
|
||||||
end: false,
|
|
||||||
showScollToBottomButton: false
|
|
||||||
};
|
|
||||||
this.dataSource = ds.cloneWithRows(this.data);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
this.updateState();
|
|
||||||
this.data.addListener(this.updateState);
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps, nextState) {
|
|
||||||
const { loadingMore, loading, end, showScollToBottomButton } = this.state;
|
|
||||||
return end !== nextState.end || loadingMore !== nextState.loadingMore || loading !== nextState.loading || showScollToBottomButton !== nextState.showScollToBottomButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
this.data.removeAllListeners();
|
|
||||||
this.updateState.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
// eslint-disable-next-line react/sort-comp
|
|
||||||
updateState = debounce(() => {
|
|
||||||
this.setState({ loading: true });
|
|
||||||
this.dataSource = this.dataSource.cloneWithRows(this.data);
|
|
||||||
this.setState({ loading: false });
|
|
||||||
}, 300);
|
|
||||||
|
|
||||||
onEndReached = async() => {
|
|
||||||
const { loadingMore, end } = this.state;
|
|
||||||
if (loadingMore || end || this.data.length < 50) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({ loadingMore: true });
|
|
||||||
const { room } = this.props;
|
|
||||||
try {
|
|
||||||
const result = await RocketChat.loadMessagesForRoom({ rid: room.rid, t: room.t, latest: this.data[this.data.length - 1].ts });
|
|
||||||
this.setState({ end: result.length < 50, loadingMore: false });
|
|
||||||
} catch (e) {
|
|
||||||
this.setState({ loadingMore: false });
|
|
||||||
log('ListView.onEndReached', e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollToBottom = () => {
|
|
||||||
this.listView.scrollTo({ x: 0, y: 0, animated: true });
|
|
||||||
}
|
|
||||||
|
|
||||||
handleScroll= (event) => {
|
|
||||||
if (event.nativeEvent.contentOffset.y > 0) {
|
|
||||||
this.setState({ showScollToBottomButton: true });
|
|
||||||
} else {
|
|
||||||
this.setState({ showScollToBottomButton: false });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderFooter = () => {
|
|
||||||
const { loadingMore, loading } = this.state;
|
|
||||||
if (loadingMore || loading) {
|
|
||||||
return <ActivityIndicator style={styles.loadingMore} />;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
getScrollButtonStyle = () => {
|
|
||||||
let right = 30;
|
|
||||||
if (isIOS) {
|
|
||||||
right = isNotch ? 45 : 30;
|
|
||||||
}
|
|
||||||
return ({
|
|
||||||
position: 'absolute',
|
|
||||||
width: 42,
|
|
||||||
height: 42,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
right,
|
|
||||||
bottom: 70,
|
|
||||||
backgroundColor: '#EAF2FE',
|
|
||||||
borderRadius: 20
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { renderRow } = this.props;
|
|
||||||
const { showScollToBottomButton } = this.state;
|
|
||||||
const scrollButtonStyle = this.getScrollButtonStyle();
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<ListView
|
|
||||||
enableEmptySections
|
|
||||||
ref={ref => this.listView = ref}
|
|
||||||
style={styles.list}
|
|
||||||
data={this.data}
|
|
||||||
keyExtractor={item => item._id}
|
|
||||||
onEndReachedThreshold={100}
|
|
||||||
renderFooter={this.renderFooter}
|
|
||||||
onEndReached={this.onEndReached}
|
|
||||||
dataSource={this.dataSource}
|
|
||||||
renderRow={(item, previousItem) => renderRow(item, previousItem)}
|
|
||||||
initialListSize={1}
|
|
||||||
pageSize={20}
|
|
||||||
onScroll={this.handleScroll}
|
|
||||||
testID='room-view-messages'
|
|
||||||
{...scrollPersistTaps}
|
|
||||||
/>
|
|
||||||
{showScollToBottomButton ? (
|
|
||||||
<TouchableOpacity activeOpacity={0.5} style={scrollButtonStyle} onPress={this.scrollToBottom}>
|
|
||||||
<CustomIcon name='arrow-down' color='white' size={30} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
) : null}
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@connect(state => ({
|
|
||||||
lastOpen: state.room.lastOpen
|
|
||||||
}), null, null, { forwardRef: true })
|
|
||||||
export class ListView extends OldList2 {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
curRenderedRowsCount: 10
|
|
||||||
// highlightedRow: ({}: Object)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
getInnerViewNode() {
|
|
||||||
return this.refs.listView.getInnerViewNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollTo(...args) {
|
|
||||||
this.refs.listView.scrollTo(...args);
|
|
||||||
}
|
|
||||||
|
|
||||||
setNativeProps(props) {
|
|
||||||
this.refs.listView.setNativeProps(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
static DataSource = DataSource;
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const bodyComponents = [];
|
|
||||||
|
|
||||||
// const stickySectionHeaderIndices = [];
|
|
||||||
|
|
||||||
// const { renderSectionHeader } = this.props;
|
|
||||||
|
|
||||||
const header = this.props.renderHeader ? this.props.renderHeader() : null;
|
|
||||||
const footer = this.props.renderFooter ? this.props.renderFooter() : null;
|
|
||||||
// let totalIndex = header ? 1 : 0;
|
|
||||||
|
|
||||||
const { data } = this.props;
|
|
||||||
let count = 0;
|
|
||||||
|
|
||||||
for (let i = 0; i < this.state.curRenderedRowsCount && i < data.length; i += 1, count += 1) {
|
|
||||||
const message = data[i];
|
|
||||||
const previousMessage = data[i + 1];
|
|
||||||
bodyComponents.push(this.props.renderRow(message, previousMessage));
|
|
||||||
|
|
||||||
|
|
||||||
if (!previousMessage) {
|
|
||||||
bodyComponents.push(<Separator key={message.ts.toISOString()} ts={message.ts} />);
|
|
||||||
continue; // eslint-disable-line
|
|
||||||
}
|
|
||||||
|
|
||||||
const showUnreadSeparator = this.props.lastOpen
|
|
||||||
&& moment(message.ts).isAfter(this.props.lastOpen)
|
|
||||||
&& moment(previousMessage.ts).isBefore(this.props.lastOpen);
|
|
||||||
const showDateSeparator = !moment(message.ts).isSame(previousMessage.ts, 'day');
|
|
||||||
|
|
||||||
if (showUnreadSeparator || showDateSeparator) {
|
|
||||||
bodyComponents.push(<Separator
|
|
||||||
key={message.ts.toISOString()}
|
|
||||||
ts={showDateSeparator ? message.ts : null}
|
|
||||||
unread={showUnreadSeparator}
|
|
||||||
/>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { ...props } = this.props;
|
|
||||||
if (!props.scrollEventThrottle) {
|
|
||||||
props.scrollEventThrottle = DEFAULT_SCROLL_CALLBACK_THROTTLE;
|
|
||||||
}
|
|
||||||
if (props.removeClippedSubviews === undefined) {
|
|
||||||
props.removeClippedSubviews = true;
|
|
||||||
}
|
|
||||||
/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
|
|
||||||
* suppresses an error found when Flow v0.54 was deployed. To see the error
|
|
||||||
* delete this comment and run Flow. */
|
|
||||||
Object.assign(props, {
|
|
||||||
onScroll: this._onScroll,
|
|
||||||
/* $FlowFixMe(>=0.53.0 site=react_native_fb,react_native_oss) This
|
|
||||||
* comment suppresses an error when upgrading Flow's support for React.
|
|
||||||
* To see the error delete this comment and run Flow. */
|
|
||||||
// stickyHeaderIndices: this.props.stickyHeaderIndices.concat(stickySectionHeaderIndices,),
|
|
||||||
|
|
||||||
// Do not pass these events downstream to ScrollView since they will be
|
|
||||||
// registered in ListView's own ScrollResponder.Mixin
|
|
||||||
onKeyboardWillShow: undefined,
|
|
||||||
onKeyboardWillHide: undefined,
|
|
||||||
onKeyboardDidShow: undefined,
|
|
||||||
onKeyboardDidHide: undefined
|
|
||||||
});
|
|
||||||
|
|
||||||
const image = data.length === 0 ? { uri: 'message_empty' } : null;
|
|
||||||
return (
|
|
||||||
[
|
|
||||||
<ImageBackground key='listview-background' source={image} style={styles.imageBackground} />,
|
|
||||||
<ScrollView
|
|
||||||
key='listview-scroll'
|
|
||||||
ref={this._setScrollComponentRef}
|
|
||||||
onContentSizeChange={this._onContentSizeChange}
|
|
||||||
onLayout={this._onLayout}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
{header}
|
|
||||||
{bodyComponents}
|
|
||||||
{footer}
|
|
||||||
</ScrollView>
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ListView.DataSource = DataSource;
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
import React from 'react';
|
||||||
|
import { TouchableOpacity, StyleSheet } from 'react-native';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
import { isNotch } from '../../utils/deviceInfo';
|
||||||
|
import { CustomIcon } from '../../lib/Icons';
|
||||||
|
import { COLOR_BUTTON_PRIMARY } from '../../constants/colors';
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
position: 'absolute',
|
||||||
|
width: 42,
|
||||||
|
height: 42,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
backgroundColor: '#EAF2FE',
|
||||||
|
borderRadius: 21,
|
||||||
|
shadowColor: '#000',
|
||||||
|
shadowOffset: {
|
||||||
|
width: 0,
|
||||||
|
height: 1
|
||||||
|
},
|
||||||
|
shadowOpacity: 0.20,
|
||||||
|
shadowRadius: 1.41,
|
||||||
|
elevation: 2
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let right;
|
||||||
|
let bottom = 80;
|
||||||
|
if (isNotch) {
|
||||||
|
bottom = 120;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ScrollBottomButton = React.memo(({ show, onPress, landscape }) => {
|
||||||
|
if (show) {
|
||||||
|
if (landscape) {
|
||||||
|
right = 45;
|
||||||
|
} else {
|
||||||
|
right = 30;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
activeOpacity={0.8}
|
||||||
|
style={[styles.button, { right, bottom }]}
|
||||||
|
onPress={onPress}
|
||||||
|
>
|
||||||
|
<CustomIcon name='arrow-down' color={COLOR_BUTTON_PRIMARY} size={30} />
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
|
||||||
|
ScrollBottomButton.propTypes = {
|
||||||
|
show: PropTypes.bool.isRequired,
|
||||||
|
onPress: PropTypes.func.isRequired,
|
||||||
|
landscape: PropTypes.bool
|
||||||
|
};
|
||||||
|
export default ScrollBottomButton;
|
|
@ -8,10 +8,9 @@ const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
marginBottom: 25,
|
marginTop: 16,
|
||||||
marginTop: 15,
|
marginBottom: 4,
|
||||||
marginHorizontal: 15,
|
marginHorizontal: 14
|
||||||
transform: [{ scaleY: -1 }]
|
|
||||||
},
|
},
|
||||||
line: {
|
line: {
|
||||||
backgroundColor: '#9ea2a8',
|
backgroundColor: '#9ea2a8',
|
||||||
|
@ -40,7 +39,7 @@ const styles = StyleSheet.create({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const DateSeparator = ({ ts, unread }) => {
|
const DateSeparator = React.memo(({ ts, unread }) => {
|
||||||
const date = ts ? moment(ts).format('MMM DD, YYYY') : null;
|
const date = ts ? moment(ts).format('MMM DD, YYYY') : null;
|
||||||
if (ts && unread) {
|
if (ts && unread) {
|
||||||
return (
|
return (
|
||||||
|
@ -65,7 +64,7 @@ const DateSeparator = ({ ts, unread }) => {
|
||||||
<View style={[styles.line, styles.unreadLine]} />
|
<View style={[styles.line, styles.unreadLine]} />
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
};
|
});
|
||||||
|
|
||||||
DateSeparator.propTypes = {
|
DateSeparator.propTypes = {
|
||||||
ts: PropTypes.instanceOf(Date),
|
ts: PropTypes.instanceOf(Date),
|
||||||
|
|
|
@ -11,6 +11,7 @@ import RocketChat from '../../lib/rocketchat';
|
||||||
import log from '../../utils/log';
|
import log from '../../utils/log';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { CustomIcon } from '../../lib/Icons';
|
import { CustomIcon } from '../../lib/Icons';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -23,7 +24,7 @@ const styles = StyleSheet.create({
|
||||||
backgroundColor: '#F1F2F4',
|
backgroundColor: '#F1F2F4',
|
||||||
height: 54,
|
height: 54,
|
||||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
borderColor: '#CACED1',
|
borderColor: COLOR_SEPARATOR,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
paddingHorizontal: 20
|
paddingHorizontal: 20
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,11 +7,12 @@ import { connect } from 'react-redux';
|
||||||
import { RectButton } from 'react-native-gesture-handler';
|
import { RectButton } from 'react-native-gesture-handler';
|
||||||
import { SafeAreaView } from 'react-navigation';
|
import { SafeAreaView } from 'react-navigation';
|
||||||
import equal from 'deep-equal';
|
import equal from 'deep-equal';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
import { openRoom as openRoomAction, closeRoom as closeRoomAction, setLastOpen as setLastOpenAction } from '../../actions/room';
|
import { openRoom as openRoomAction, closeRoom as closeRoomAction } from '../../actions/room';
|
||||||
import { toggleReactionPicker as toggleReactionPickerAction, actionsShow as actionsShowAction } from '../../actions/messages';
|
import { toggleReactionPicker as toggleReactionPickerAction, actionsShow as actionsShowAction } from '../../actions/messages';
|
||||||
import LoggedView from '../View';
|
import LoggedView from '../View';
|
||||||
import { List } from './ListView';
|
import { List } from './List';
|
||||||
import database from '../../lib/realm';
|
import database from '../../lib/realm';
|
||||||
import RocketChat from '../../lib/rocketchat';
|
import RocketChat from '../../lib/rocketchat';
|
||||||
import Message from '../../containers/message';
|
import Message from '../../containers/message';
|
||||||
|
@ -28,6 +29,7 @@ import ConnectionBadge from '../../containers/ConnectionBadge';
|
||||||
import { CustomHeaderButtons, Item } from '../../containers/HeaderButton';
|
import { CustomHeaderButtons, Item } from '../../containers/HeaderButton';
|
||||||
import RoomHeaderView from './Header';
|
import RoomHeaderView from './Header';
|
||||||
import StatusBar from '../../containers/StatusBar';
|
import StatusBar from '../../containers/StatusBar';
|
||||||
|
import Separator from './Separator';
|
||||||
|
|
||||||
@connect(state => ({
|
@connect(state => ({
|
||||||
user: {
|
user: {
|
||||||
|
@ -41,7 +43,6 @@ import StatusBar from '../../containers/StatusBar';
|
||||||
appState: state.app.ready && state.app.foreground ? 'foreground' : 'background'
|
appState: state.app.ready && state.app.foreground ? 'foreground' : 'background'
|
||||||
}), dispatch => ({
|
}), dispatch => ({
|
||||||
openRoom: room => dispatch(openRoomAction(room)),
|
openRoom: room => dispatch(openRoomAction(room)),
|
||||||
setLastOpen: date => dispatch(setLastOpenAction(date)),
|
|
||||||
toggleReactionPicker: message => dispatch(toggleReactionPickerAction(message)),
|
toggleReactionPicker: message => dispatch(toggleReactionPickerAction(message)),
|
||||||
actionsShow: actionMessage => dispatch(actionsShowAction(actionMessage)),
|
actionsShow: actionMessage => dispatch(actionsShowAction(actionMessage)),
|
||||||
closeRoom: () => dispatch(closeRoomAction())
|
closeRoom: () => dispatch(closeRoomAction())
|
||||||
|
@ -70,7 +71,6 @@ export default class RoomView extends LoggedView {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
navigation: PropTypes.object,
|
navigation: PropTypes.object,
|
||||||
openRoom: PropTypes.func.isRequired,
|
openRoom: PropTypes.func.isRequired,
|
||||||
setLastOpen: PropTypes.func.isRequired,
|
|
||||||
user: PropTypes.shape({
|
user: PropTypes.shape({
|
||||||
id: PropTypes.string.isRequired,
|
id: PropTypes.string.isRequired,
|
||||||
username: PropTypes.string.isRequired,
|
username: PropTypes.string.isRequired,
|
||||||
|
@ -92,9 +92,14 @@ export default class RoomView extends LoggedView {
|
||||||
this.state = {
|
this.state = {
|
||||||
loaded: false,
|
loaded: false,
|
||||||
joined: this.rooms.length > 0,
|
joined: this.rooms.length > 0,
|
||||||
room: {}
|
room: {},
|
||||||
|
lastOpen: null
|
||||||
};
|
};
|
||||||
|
this.beginAnimating = false;
|
||||||
this.onReactionPress = this.onReactionPress.bind(this);
|
this.onReactionPress = this.onReactionPress.bind(this);
|
||||||
|
setTimeout(() => {
|
||||||
|
this.beginAnimating = true;
|
||||||
|
}, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
@ -181,7 +186,7 @@ export default class RoomView extends LoggedView {
|
||||||
};
|
};
|
||||||
|
|
||||||
internalSetState = (...args) => {
|
internalSetState = (...args) => {
|
||||||
if (isIOS) {
|
if (isIOS && this.beginAnimating) {
|
||||||
LayoutAnimation.easeInEaseOut();
|
LayoutAnimation.easeInEaseOut();
|
||||||
}
|
}
|
||||||
this.setState(...args);
|
this.setState(...args);
|
||||||
|
@ -189,7 +194,7 @@ export default class RoomView extends LoggedView {
|
||||||
|
|
||||||
// eslint-disable-next-line react/sort-comp
|
// eslint-disable-next-line react/sort-comp
|
||||||
updateRoom = () => {
|
updateRoom = () => {
|
||||||
const { openRoom, setLastOpen } = this.props;
|
const { openRoom } = this.props;
|
||||||
|
|
||||||
if (this.rooms.length > 0) {
|
if (this.rooms.length > 0) {
|
||||||
const { room: prevRoom } = this.state;
|
const { room: prevRoom } = this.state;
|
||||||
|
@ -201,9 +206,9 @@ export default class RoomView extends LoggedView {
|
||||||
...room
|
...room
|
||||||
});
|
});
|
||||||
if (room.alert || room.unread || room.userMentions) {
|
if (room.alert || room.unread || room.userMentions) {
|
||||||
setLastOpen(room.ls);
|
this.setLastOpen(room.ls);
|
||||||
} else {
|
} else {
|
||||||
setLastOpen(null);
|
this.setLastOpen(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -226,13 +231,14 @@ export default class RoomView extends LoggedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage = (message) => {
|
sendMessage = (message) => {
|
||||||
const { setLastOpen } = this.props;
|
|
||||||
LayoutAnimation.easeInEaseOut();
|
LayoutAnimation.easeInEaseOut();
|
||||||
RocketChat.sendMessage(this.rid, message).then(() => {
|
RocketChat.sendMessage(this.rid, message).then(() => {
|
||||||
setLastOpen(null);
|
this.setLastOpen(null);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
setLastOpen = lastOpen => this.setState({ lastOpen });
|
||||||
|
|
||||||
joinRoom = async() => {
|
joinRoom = async() => {
|
||||||
try {
|
try {
|
||||||
const result = await RocketChat.joinRoom(this.rid);
|
const result = await RocketChat.joinRoom(this.rid);
|
||||||
|
@ -275,8 +281,46 @@ export default class RoomView extends LoggedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
renderItem = (item, previousItem) => {
|
renderItem = (item, previousItem) => {
|
||||||
const { room } = this.state;
|
const { room, lastOpen } = this.state;
|
||||||
const { user } = this.props;
|
const { user } = this.props;
|
||||||
|
let dateSeparator = null;
|
||||||
|
let showUnreadSeparator = false;
|
||||||
|
|
||||||
|
if (!previousItem) {
|
||||||
|
dateSeparator = item.ts;
|
||||||
|
showUnreadSeparator = moment(item.ts).isAfter(lastOpen);
|
||||||
|
} else {
|
||||||
|
showUnreadSeparator = lastOpen
|
||||||
|
&& moment(item.ts).isAfter(lastOpen)
|
||||||
|
&& moment(previousItem.ts).isBefore(lastOpen);
|
||||||
|
if (!moment(item.ts).isSame(previousItem.ts, 'day')) {
|
||||||
|
dateSeparator = previousItem.ts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showUnreadSeparator || dateSeparator) {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<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}
|
||||||
|
/>
|
||||||
|
<Separator
|
||||||
|
ts={dateSeparator}
|
||||||
|
unread={showUnreadSeparator}
|
||||||
|
/>
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Message
|
<Message
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
typing: { fontWeight: 'bold', paddingHorizontal: 15, height: 25 },
|
typing: { fontWeight: 'bold', paddingHorizontal: 15, height: 25 },
|
||||||
|
@ -10,12 +11,11 @@ export default StyleSheet.create({
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
flex: 1,
|
flex: 1
|
||||||
transform: [{ scaleY: -1 }]
|
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
height: 1,
|
height: 1,
|
||||||
backgroundColor: '#CED0CE'
|
backgroundColor: COLOR_SEPARATOR
|
||||||
},
|
},
|
||||||
bannerContainer: {
|
bannerContainer: {
|
||||||
backgroundColor: 'orange'
|
backgroundColor: 'orange'
|
||||||
|
@ -26,7 +26,6 @@ export default StyleSheet.create({
|
||||||
color: '#a00'
|
color: '#a00'
|
||||||
},
|
},
|
||||||
loadingMore: {
|
loadingMore: {
|
||||||
transform: [{ scaleY: -1 }],
|
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
padding: 15,
|
padding: 15,
|
||||||
color: '#ccc'
|
color: '#ccc'
|
||||||
|
@ -46,11 +45,6 @@ export default StyleSheet.create({
|
||||||
loading: {
|
loading: {
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
imageBackground: {
|
|
||||||
width: '100%',
|
|
||||||
height: '100%',
|
|
||||||
position: 'absolute'
|
|
||||||
},
|
|
||||||
joinRoomContainer: {
|
joinRoomContainer: {
|
||||||
justifyContent: 'flex-end',
|
justifyContent: 'flex-end',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
|
|
|
@ -245,7 +245,8 @@ export default class RoomsListView extends LoggedView {
|
||||||
}
|
}
|
||||||
|
|
||||||
internalSetState = (...args) => {
|
internalSetState = (...args) => {
|
||||||
if (isIOS) {
|
const { navigation } = this.props;
|
||||||
|
if (isIOS && navigation.isFocused()) {
|
||||||
LayoutAnimation.easeInEaseOut();
|
LayoutAnimation.easeInEaseOut();
|
||||||
}
|
}
|
||||||
this.setState(...args);
|
this.setState(...args);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
import { isIOS } from '../../utils/deviceInfo';
|
import { isIOS } from '../../utils/deviceInfo';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -8,8 +9,8 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#E1E5E8',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
marginLeft: 78
|
marginLeft: 73
|
||||||
},
|
},
|
||||||
list: {
|
list: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
|
@ -36,7 +37,7 @@ export default StyleSheet.create({
|
||||||
dropdownContainerHeader: {
|
dropdownContainerHeader: {
|
||||||
height: 41,
|
height: 41,
|
||||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
borderColor: '#E1E5E8',
|
borderColor: COLOR_SEPARATOR,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: isIOS ? '#fff' : '#54585E',
|
backgroundColor: isIOS ? '#fff' : '#54585E',
|
||||||
flexDirection: 'row'
|
flexDirection: 'row'
|
||||||
|
@ -79,7 +80,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
sortSeparator: {
|
sortSeparator: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#CBCED1',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
marginHorizontal: 15,
|
marginHorizontal: 15,
|
||||||
flex: 1
|
flex: 1
|
||||||
},
|
},
|
||||||
|
@ -154,7 +155,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
serverSeparator: {
|
serverSeparator: {
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#E1E5E8',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
marginLeft: 72
|
marginLeft: 72
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -19,7 +20,7 @@ export default StyleSheet.create({
|
||||||
divider: {
|
divider: {
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: StyleSheet.hairlineWidth,
|
height: StyleSheet.hairlineWidth,
|
||||||
backgroundColor: '#E7EBF2',
|
backgroundColor: COLOR_SEPARATOR,
|
||||||
marginVertical: 20
|
marginVertical: 20
|
||||||
},
|
},
|
||||||
listEmptyContainer: {
|
listEmptyContainer: {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { StyleSheet } from 'react-native';
|
import { StyleSheet } from 'react-native';
|
||||||
|
import { COLOR_SEPARATOR } from '../../constants/colors';
|
||||||
|
|
||||||
export default StyleSheet.create({
|
export default StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
@ -27,7 +28,7 @@ export default StyleSheet.create({
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
borderBottomWidth: StyleSheet.hairlineWidth,
|
borderBottomWidth: StyleSheet.hairlineWidth,
|
||||||
borderColor: '#E1E5E8',
|
borderColor: COLOR_SEPARATOR,
|
||||||
marginVertical: 4
|
marginVertical: 4
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
|
|
|
@ -117,8 +117,8 @@ describe('Create room screen', () => {
|
||||||
await element(by.id('create-channel-submit')).tap();
|
await element(by.id('create-channel-submit')).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
||||||
await expect(element(by.id('room-view'))).toBeVisible();
|
await expect(element(by.id('room-view'))).toBeVisible();
|
||||||
await waitFor(element(by.text(room))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.text(room))).toExist().withTimeout(60000);
|
||||||
await expect(element(by.text(room))).toBeVisible();
|
await expect(element(by.text(room))).toExist();
|
||||||
await tapBack();
|
await tapBack();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
||||||
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id(`rooms-list-view-item-${ room }`))).toBeVisible().withTimeout(60000);
|
||||||
|
@ -141,8 +141,8 @@ describe('Create room screen', () => {
|
||||||
await element(by.id('create-channel-submit')).tap();
|
await element(by.id('create-channel-submit')).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
||||||
await expect(element(by.id('room-view'))).toBeVisible();
|
await expect(element(by.id('room-view'))).toBeVisible();
|
||||||
await waitFor(element(by.text(room))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.text(room))).toExist().withTimeout(60000);
|
||||||
await expect(element(by.text(room))).toBeVisible();
|
await expect(element(by.text(room))).toExist();
|
||||||
await tapBack();
|
await tapBack();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
||||||
await element(by.id('rooms-list-view-search')).replaceText(room);
|
await element(by.id('rooms-list-view-search')).replaceText(room);
|
||||||
|
@ -165,8 +165,8 @@ describe('Create room screen', () => {
|
||||||
await element(by.id('create-channel-submit')).tap();
|
await element(by.id('create-channel-submit')).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
||||||
await expect(element(by.id('room-view'))).toBeVisible();
|
await expect(element(by.id('room-view'))).toBeVisible();
|
||||||
await waitFor(element(by.text(room))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.text(room))).toExist().withTimeout(60000);
|
||||||
await expect(element(by.text(room))).toBeVisible();
|
await expect(element(by.text(room))).toExist();
|
||||||
await tapBack();
|
await tapBack();
|
||||||
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
await waitFor(element(by.id('rooms-list-view'))).toBeVisible().withTimeout(2000);
|
||||||
await element(by.id('rooms-list-view-search')).replaceText(room);
|
await element(by.id('rooms-list-view-search')).replaceText(room);
|
||||||
|
|
|
@ -26,8 +26,8 @@ describe('Broadcast room', () => {
|
||||||
await element(by.id('create-channel-submit')).tap();
|
await element(by.id('create-channel-submit')).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(60000);
|
||||||
await expect(element(by.id('room-view'))).toBeVisible();
|
await expect(element(by.id('room-view'))).toBeVisible();
|
||||||
await waitFor(element(by.text(`broadcast${ data.random }`))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.text(`broadcast${ data.random }`))).toExist().withTimeout(60000);
|
||||||
await expect(element(by.text(`broadcast${ data.random }`))).toBeVisible();
|
await expect(element(by.text(`broadcast${ data.random }`))).toExist();
|
||||||
await element(by.id('room-view-header-actions')).tap();
|
await element(by.id('room-view-header-actions')).tap();
|
||||||
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('room-actions-view'))).toBeVisible().withTimeout(5000);
|
||||||
await element(by.id('room-actions-info')).tap();
|
await element(by.id('room-actions-info')).tap();
|
||||||
|
@ -76,8 +76,8 @@ describe('Broadcast room', () => {
|
||||||
await expect(element(by.id(`rooms-list-view-item-broadcast${ data.random }`))).toExist();
|
await expect(element(by.id(`rooms-list-view-item-broadcast${ data.random }`))).toExist();
|
||||||
await element(by.id(`rooms-list-view-item-broadcast${ data.random }`)).tap();
|
await element(by.id(`rooms-list-view-item-broadcast${ data.random }`)).tap();
|
||||||
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
await waitFor(element(by.id('room-view'))).toBeVisible().withTimeout(5000);
|
||||||
await waitFor(element(by.text(`broadcast${ data.random }`))).toBeVisible().withTimeout(60000);
|
await waitFor(element(by.text(`broadcast${ data.random }`))).toExist().withTimeout(60000);
|
||||||
await expect(element(by.text(`broadcast${ data.random }`))).toBeVisible();
|
await expect(element(by.text(`broadcast${ data.random }`))).toExist();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not have messagebox', async() => {
|
it('should not have messagebox', async() => {
|
||||||
|
|
|
@ -7,7 +7,7 @@ const data = {
|
||||||
password: `password${ value }`,
|
password: `password${ value }`,
|
||||||
alternateUser: 'detoxrn',
|
alternateUser: 'detoxrn',
|
||||||
alternateUserPassword: '123',
|
alternateUserPassword: '123',
|
||||||
alternateUserTOTPSecret: 'KESVIUCQMZWEYNBMJJAUW4LYKRBVWYZ7HBWTIWDPIAZUOURTF4WA',
|
alternateUserTOTPSecret: 'I5SGETK3GBXXA7LNLMZTEJJRIN3G6LTEEE4G4PS3EQRXU4LNPU7A',
|
||||||
email: `diego.mello+e2e${ value }@rocket.chat`,
|
email: `diego.mello+e2e${ value }@rocket.chat`,
|
||||||
random: value
|
random: value
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,8 @@ import MessageSeparator from '../../app/views/RoomView/Separator';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
separator: {
|
separator: {
|
||||||
transform: [{ scaleY: -1 }],
|
marginTop: 30,
|
||||||
marginBottom: 30,
|
marginBottom: 0
|
||||||
marginTop: 0
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,14 +43,15 @@ const Message = props => (
|
||||||
const Separator = ({ title }) => <StoriesSeparator title={title} style={styles.separator} />;
|
const Separator = ({ title }) => <StoriesSeparator title={title} style={styles.separator} />;
|
||||||
|
|
||||||
export default (
|
export default (
|
||||||
<ScrollView style={{ flex: 1, transform: [{ scaleY: -1 }] }} contentContainerStyle={{ marginVertical: 30 }}>
|
<ScrollView style={{ flex: 1 }} contentContainerStyle={{ marginVertical: 30 }}>
|
||||||
|
|
||||||
<Message msg='Message' />
|
|
||||||
<Separator title='Simple' />
|
<Separator title='Simple' />
|
||||||
|
<Message msg='Message' />
|
||||||
|
|
||||||
<Message msg='Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum' />
|
|
||||||
<Separator title='Long message' />
|
<Separator title='Long message' />
|
||||||
|
<Message msg='Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum' />
|
||||||
|
|
||||||
|
<Separator title='Grouped messages' />
|
||||||
<Message msg='...' />
|
<Message msg='...' />
|
||||||
<Message
|
<Message
|
||||||
msg='Different user'
|
msg='Different user'
|
||||||
|
@ -63,23 +63,23 @@ export default (
|
||||||
<Message msg='This is the third message' header={false} />
|
<Message msg='This is the third message' header={false} />
|
||||||
<Message msg='This is the second message' header={false} />
|
<Message msg='This is the second message' header={false} />
|
||||||
<Message msg='This is the first message' />
|
<Message msg='This is the first message' />
|
||||||
<Separator title='Grouped messages' />
|
|
||||||
|
|
||||||
<Message msg='Message' header={false} />
|
|
||||||
<Separator title='Without header' />
|
<Separator title='Without header' />
|
||||||
|
<Message msg='Message' header={false} />
|
||||||
|
|
||||||
<Message msg='Message' alias='Diego Mello' />
|
|
||||||
<Separator title='With alias' />
|
<Separator title='With alias' />
|
||||||
|
<Message msg='Message' alias='Diego Mello' />
|
||||||
|
|
||||||
<Message msg='Message' edited />
|
|
||||||
<Separator title='Edited' />
|
<Separator title='Edited' />
|
||||||
|
<Message msg='Message' edited />
|
||||||
|
|
||||||
|
<Separator title='Static avatar' />
|
||||||
<Message
|
<Message
|
||||||
msg='Message'
|
msg='Message'
|
||||||
avatar='https://pbs.twimg.com/profile_images/1016397063649660929/14EIApTi_400x400.jpg'
|
avatar='https://pbs.twimg.com/profile_images/1016397063649660929/14EIApTi_400x400.jpg'
|
||||||
/>
|
/>
|
||||||
<Separator title='Static avatar' />
|
|
||||||
|
|
||||||
|
<Separator title='Full name' />
|
||||||
<Message
|
<Message
|
||||||
msg='Message'
|
msg='Message'
|
||||||
author={{
|
author={{
|
||||||
|
@ -89,20 +89,20 @@ export default (
|
||||||
}}
|
}}
|
||||||
useRealName
|
useRealName
|
||||||
/>
|
/>
|
||||||
<Separator title='Full name' />
|
|
||||||
|
|
||||||
<Message msg='@rocket.cat @diego.mello @all @here #general' />
|
|
||||||
<Separator title='Mentions' />
|
<Separator title='Mentions' />
|
||||||
|
<Message msg='@rocket.cat @diego.mello @all @here #general' />
|
||||||
|
|
||||||
<Message msg='👊🤙👏' />
|
|
||||||
<Separator title='Emojis' />
|
<Separator title='Emojis' />
|
||||||
|
<Message msg='👊🤙👏' />
|
||||||
|
|
||||||
<Message msg=':react_rocket: :nyan_rocket: :marioparty:' />
|
|
||||||
<Separator title='Custom Emojis' />
|
<Separator title='Custom Emojis' />
|
||||||
|
<Message msg=':react_rocket: :nyan_rocket: :marioparty:' />
|
||||||
|
|
||||||
<Message msg='Testing' timeFormat='DD MMMM YYYY' />
|
|
||||||
<Separator title='Time format' />
|
<Separator title='Time format' />
|
||||||
|
<Message msg='Testing' timeFormat='DD MMMM YYYY' />
|
||||||
|
|
||||||
|
<Separator title='Reactions' />
|
||||||
<Message
|
<Message
|
||||||
msg='Reactions'
|
msg='Reactions'
|
||||||
reactions={[{
|
reactions={[{
|
||||||
|
@ -117,8 +117,8 @@ export default (
|
||||||
}]}
|
}]}
|
||||||
onReactionPress={() => {}}
|
onReactionPress={() => {}}
|
||||||
/>
|
/>
|
||||||
<Separator title='Reactions' />
|
|
||||||
|
|
||||||
|
<Separator title='Multiple reactions' />
|
||||||
<Message
|
<Message
|
||||||
msg='Multiple Reactions'
|
msg='Multiple Reactions'
|
||||||
reactions={[{
|
reactions={[{
|
||||||
|
@ -148,8 +148,8 @@ export default (
|
||||||
}]}
|
}]}
|
||||||
onReactionPress={() => {}}
|
onReactionPress={() => {}}
|
||||||
/>
|
/>
|
||||||
<Separator title='Multiple reactions' />
|
|
||||||
|
|
||||||
|
<Separator title='Intercalated users' />
|
||||||
<Message
|
<Message
|
||||||
msg='Fourth message'
|
msg='Fourth message'
|
||||||
author={{
|
author={{
|
||||||
|
@ -166,8 +166,8 @@ export default (
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Message msg='First message' />
|
<Message msg='First message' />
|
||||||
<Separator title='Intercalated users' />
|
|
||||||
|
|
||||||
|
<Separator title='Date and Unread separators' />
|
||||||
<Message
|
<Message
|
||||||
msg='Fourth message'
|
msg='Fourth message'
|
||||||
author={{
|
author={{
|
||||||
|
@ -195,8 +195,8 @@ export default (
|
||||||
/>
|
/>
|
||||||
<MessageSeparator ts={date} />
|
<MessageSeparator ts={date} />
|
||||||
<Message msg='First message' />
|
<Message msg='First message' />
|
||||||
<Separator title='Date and Unread separators' />
|
|
||||||
|
|
||||||
|
<Separator title='With image' />
|
||||||
<Message
|
<Message
|
||||||
attachments={[{
|
attachments={[{
|
||||||
title: 'This is a title',
|
title: 'This is a title',
|
||||||
|
@ -211,8 +211,8 @@ export default (
|
||||||
image_url: '/file-upload/sxLXBzjwuqxMnebyP/Clipboard%20-%2029%20de%20Agosto%20de%202018%20%C3%A0s%2018:10'
|
image_url: '/file-upload/sxLXBzjwuqxMnebyP/Clipboard%20-%2029%20de%20Agosto%20de%202018%20%C3%A0s%2018:10'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='With image' />
|
|
||||||
|
|
||||||
|
<Separator title='With video' />
|
||||||
<Message
|
<Message
|
||||||
attachments={[{
|
attachments={[{
|
||||||
title: 'This is a title',
|
title: 'This is a title',
|
||||||
|
@ -220,8 +220,8 @@ export default (
|
||||||
video_url: '/file-upload/cqnKqb6kdajky5Rxj/WhatsApp%20Video%202018-08-22%20at%2019.09.55.mp4'
|
video_url: '/file-upload/cqnKqb6kdajky5Rxj/WhatsApp%20Video%202018-08-22%20at%2019.09.55.mp4'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='With video' />
|
|
||||||
|
|
||||||
|
<Separator title='With audio' />
|
||||||
<Message
|
<Message
|
||||||
attachments={[{
|
attachments={[{
|
||||||
title: 'This is a title',
|
title: 'This is a title',
|
||||||
|
@ -229,8 +229,8 @@ export default (
|
||||||
audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac'
|
audio_url: '/file-upload/c4wcNhrbXJLBvAJtN/1535569819516.aac'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='With audio' />
|
|
||||||
|
|
||||||
|
<Separator title='Message with reply' />
|
||||||
<Message
|
<Message
|
||||||
msg="I'm fine!"
|
msg="I'm fine!"
|
||||||
attachments={[{
|
attachments={[{
|
||||||
|
@ -249,8 +249,8 @@ export default (
|
||||||
text: 'How are you?'
|
text: 'How are you?'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='Message with reply' />
|
|
||||||
|
|
||||||
|
<Separator title='URL' />
|
||||||
<Message
|
<Message
|
||||||
urls={[{
|
urls={[{
|
||||||
url: 'https://rocket.chat',
|
url: 'https://rocket.chat',
|
||||||
|
@ -263,8 +263,8 @@ export default (
|
||||||
description: 'Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for.'
|
description: 'Search the world\'s information, including webpages, images, videos and more. Google has many special features to help you find exactly what you\'re looking for.'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='URL' />
|
|
||||||
|
|
||||||
|
<Separator title='Custom fields' />
|
||||||
<Message
|
<Message
|
||||||
msg='Message'
|
msg='Message'
|
||||||
attachments={[{
|
attachments={[{
|
||||||
|
@ -290,8 +290,8 @@ export default (
|
||||||
}]
|
}]
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='Custom fields' />
|
|
||||||
|
|
||||||
|
<Separator title='Two short custom fields' />
|
||||||
<Message
|
<Message
|
||||||
msg='Message'
|
msg='Message'
|
||||||
attachments={[{
|
attachments={[{
|
||||||
|
@ -324,33 +324,33 @@ export default (
|
||||||
}]
|
}]
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='Two short custom fields' />
|
|
||||||
|
|
||||||
<Message msg='Broadcasted message' broadcast replyBroadcast={() => alert('broadcast!')} />
|
|
||||||
<Separator title='Broadcast' />
|
<Separator title='Broadcast' />
|
||||||
|
<Message msg='Broadcasted message' broadcast replyBroadcast={() => alert('broadcast!')} />
|
||||||
|
|
||||||
<Message msg='This message is inside an archived room' archived />
|
|
||||||
<Separator title='Archived' />
|
<Separator title='Archived' />
|
||||||
|
<Message msg='This message is inside an archived room' archived />
|
||||||
|
|
||||||
|
<Separator title='Error' />
|
||||||
<Message msg='This message has error too' status={messagesStatus.ERROR} onErrorPress={() => alert('Error pressed')} header={false} />
|
<Message msg='This message has error too' status={messagesStatus.ERROR} onErrorPress={() => alert('Error pressed')} header={false} />
|
||||||
<Message msg='This message has error' status={messagesStatus.ERROR} onErrorPress={() => alert('Error pressed')} />
|
<Message msg='This message has error' status={messagesStatus.ERROR} onErrorPress={() => alert('Error pressed')} />
|
||||||
<Separator title='Error' />
|
|
||||||
|
|
||||||
<Message msg='Temp message' status={messagesStatus.TEMP} />
|
|
||||||
<Separator title='Temp' />
|
<Separator title='Temp' />
|
||||||
|
<Message msg='Temp message' status={messagesStatus.TEMP} />
|
||||||
|
|
||||||
<Message msg='Message being edited' editing />
|
|
||||||
<Separator title='Editing' />
|
<Separator title='Editing' />
|
||||||
|
<Message msg='Message being edited' editing />
|
||||||
|
|
||||||
<Message type='rm' />
|
|
||||||
<Separator title='Removed' />
|
<Separator title='Removed' />
|
||||||
|
<Message type='rm' />
|
||||||
|
|
||||||
<Message type='uj' />
|
|
||||||
<Separator title='Joined' />
|
<Separator title='Joined' />
|
||||||
|
<Message type='uj' />
|
||||||
|
|
||||||
<Message msg='New name' type='r' />
|
|
||||||
<Separator title='Room name changed' />
|
<Separator title='Room name changed' />
|
||||||
|
<Message msg='New name' type='r' />
|
||||||
|
|
||||||
|
<Separator title='Message pinned' />
|
||||||
<Message
|
<Message
|
||||||
msg='New name'
|
msg='New name'
|
||||||
type='message_pinned'
|
type='message_pinned'
|
||||||
|
@ -361,55 +361,55 @@ export default (
|
||||||
text: 'First message'
|
text: 'First message'
|
||||||
}]}
|
}]}
|
||||||
/>
|
/>
|
||||||
<Separator title='Message pinned' />
|
|
||||||
|
|
||||||
<Message type='ul' />
|
|
||||||
<Separator title='Has left the channel' />
|
<Separator title='Has left the channel' />
|
||||||
|
<Message type='ul' />
|
||||||
|
|
||||||
<Message msg='rocket.cat' type='ru' />
|
|
||||||
<Separator title='User removed' />
|
<Separator title='User removed' />
|
||||||
|
<Message msg='rocket.cat' type='ru' />
|
||||||
|
|
||||||
<Message msg='rocket.cat' type='au' />
|
|
||||||
<Separator title='User added' />
|
<Separator title='User added' />
|
||||||
|
<Message msg='rocket.cat' type='au' />
|
||||||
|
|
||||||
<Message msg='rocket.cat' type='user-muted' />
|
|
||||||
<Separator title='User muted' />
|
<Separator title='User muted' />
|
||||||
|
<Message msg='rocket.cat' type='user-muted' />
|
||||||
|
|
||||||
<Message msg='rocket.cat' type='user-unmuted' />
|
|
||||||
<Separator title='User unmuted' />
|
<Separator title='User unmuted' />
|
||||||
|
<Message msg='rocket.cat' type='user-unmuted' />
|
||||||
|
|
||||||
|
<Separator title='Role added' />
|
||||||
<Message
|
<Message
|
||||||
msg='rocket.cat'
|
msg='rocket.cat'
|
||||||
role='admin' // eslint-disable-line
|
role='admin' // eslint-disable-line
|
||||||
type='subscription-role-added'
|
type='subscription-role-added'
|
||||||
/>
|
/>
|
||||||
<Separator title='Role added' />
|
|
||||||
|
|
||||||
|
<Separator title='Role removed' />
|
||||||
<Message
|
<Message
|
||||||
msg='rocket.cat'
|
msg='rocket.cat'
|
||||||
role='admin' // eslint-disable-line
|
role='admin' // eslint-disable-line
|
||||||
type='subscription-role-removed'
|
type='subscription-role-removed'
|
||||||
/>
|
/>
|
||||||
<Separator title='Role removed' />
|
|
||||||
|
|
||||||
<Message msg='new description' type='room_changed_description' />
|
|
||||||
<Separator title='Changed description' />
|
<Separator title='Changed description' />
|
||||||
|
<Message msg='new description' type='room_changed_description' />
|
||||||
|
|
||||||
<Message msg='new announcement' type='room_changed_announcement' />
|
|
||||||
<Separator title='Changed announcement' />
|
<Separator title='Changed announcement' />
|
||||||
|
<Message msg='new announcement' type='room_changed_announcement' />
|
||||||
|
|
||||||
<Message msg='new topic' type='room_changed_topic' />
|
|
||||||
<Separator title='Changed topic' />
|
<Separator title='Changed topic' />
|
||||||
|
<Message msg='new topic' type='room_changed_topic' />
|
||||||
|
|
||||||
<Message msg='public' type='room_changed_privacy' />
|
|
||||||
<Separator title='Changed type' />
|
<Separator title='Changed type' />
|
||||||
|
<Message msg='public' type='room_changed_privacy' />
|
||||||
|
|
||||||
<Message msg='Message' style={[styles.normalize, { backgroundColor: '#ddd' }]} />
|
|
||||||
<Separator title='Custom style' />
|
<Separator title='Custom style' />
|
||||||
|
<Message msg='Message' style={[styles.normalize, { backgroundColor: '#ddd' }]} />
|
||||||
|
|
||||||
<Message msg='Italic with *asterisks* or _underscores_. Bold with **asterisks** or __underscores__. ~~Strikethrough~~' />
|
|
||||||
<Separator title='Markdown emphasis' />
|
<Separator title='Markdown emphasis' />
|
||||||
|
<Message msg='Italic with *asterisks* or _underscores_. Bold with **asterisks** or __underscores__. ~~Strikethrough~~' />
|
||||||
|
|
||||||
|
<Separator title='Markdown headers' />
|
||||||
<Message
|
<Message
|
||||||
msg='# H1
|
msg='# H1
|
||||||
## H2
|
## H2
|
||||||
|
@ -418,31 +418,30 @@ export default (
|
||||||
##### H5
|
##### H5
|
||||||
###### H6'
|
###### H6'
|
||||||
/>
|
/>
|
||||||
<Separator title='Markdown headers' />
|
|
||||||
|
|
||||||
<Message msg='Support <http://google.com|Google> [I`m an inline-style link](https://www.google.com) https://google.com' />
|
|
||||||
<Separator title='Markdown links' />
|
<Separator title='Markdown links' />
|
||||||
|
<Message msg='Support <http://google.com|Google> [I`m an inline-style link](https://www.google.com) https://google.com' />
|
||||||
|
|
||||||
<Message msg='![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)' />
|
|
||||||
<Separator title='Markdown image' />
|
<Separator title='Markdown image' />
|
||||||
|
<Message msg='![alt text](https://play.google.com/intl/en_us/badges/images/badge_new.png)' />
|
||||||
|
|
||||||
|
<Separator title='Markdown code' />
|
||||||
<Message
|
<Message
|
||||||
msg='Inline `code` has `back-ticks around` it.
|
msg='Inline `code` has `back-ticks around` it.
|
||||||
```
|
```
|
||||||
Code block
|
Code block
|
||||||
```'
|
```'
|
||||||
/>
|
/>
|
||||||
<Separator title='Markdown code' />
|
|
||||||
|
|
||||||
<Message msg='> Quote' />
|
|
||||||
<Separator title='Markdown quote' />
|
<Separator title='Markdown quote' />
|
||||||
|
<Message msg='> Quote' />
|
||||||
|
|
||||||
|
<Separator title='Markdown table' />
|
||||||
<Message
|
<Message
|
||||||
msg='First Header | Second Header
|
msg='First Header | Second Header
|
||||||
------------ | -------------
|
------------ | -------------
|
||||||
Content from cell 1 | Content from cell 2
|
Content from cell 1 | Content from cell 2
|
||||||
Content in the first column | Content in the second column'
|
Content in the first column | Content in the second column'
|
||||||
/>
|
/>
|
||||||
<Separator title='Markdown table' />
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue