This commit is contained in:
Guilherme Gazzo 2018-02-14 19:26:15 -02:00
parent 6a1d9a3c7d
commit 40cb3e536b
No known key found for this signature in database
GPG Key ID: 1F85C9AD922D0829
6 changed files with 1548 additions and 730 deletions

View File

@ -33,10 +33,12 @@ exports[`render channel 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -53,8 +55,8 @@ exports[`render channel 1`] = `
Object {
"backgroundColor": "#00BCD4",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -75,7 +77,7 @@ exports[`render channel 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
],
Object {
@ -93,10 +95,67 @@ exports[`render channel 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
general
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -108,33 +167,21 @@ exports[`render channel 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
general
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
</View>
</View>
</View>
</View>
`;
exports[`render no icon 1`] = `
@ -170,10 +217,12 @@ exports[`render no icon 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -190,8 +239,8 @@ exports[`render no icon 1`] = `
Object {
"backgroundColor": "#3F51B5",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -212,7 +261,7 @@ exports[`render no icon 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
],
Object {
@ -230,10 +279,67 @@ exports[`render no icon 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -245,33 +351,21 @@ exports[`render no icon 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
</View>
</View>
</View>
</View>
`;
exports[`render private group 1`] = `
@ -307,10 +401,12 @@ exports[`render private group 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -327,8 +423,8 @@ exports[`render private group 1`] = `
Object {
"backgroundColor": "#FF9800",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -349,7 +445,7 @@ exports[`render private group 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
],
Object {
@ -367,10 +463,67 @@ exports[`render private group 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
private-group
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -382,32 +535,20 @@ exports[`render private group 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
private-group
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
</View>
</View>
</View>
</View>
`;
@ -445,10 +586,12 @@ exports[`render unread +999 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -465,8 +608,8 @@ exports[`render unread +999 1`] = `
Object {
"backgroundColor": "#3F51B5",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -482,7 +625,7 @@ exports[`render unread +999 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
]
}
@ -495,10 +638,67 @@ exports[`render unread +999 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -510,44 +710,32 @@ exports[`render unread +999 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"alignItems": "center",
"backgroundColor": "#1d74f5",
"borderRadius": 3,
"borderRadius": 4,
"color": "#fff",
"fontSize": 14,
"minWidth": 20,
"justifyContent": "center",
"minWidth": 25,
"overflow": "hidden",
"paddingHorizontal": 5,
"paddingVertical": 2,
"paddingVertical": 4,
"textAlign": "center",
}
}
@ -557,6 +745,8 @@ exports[`render unread +999 1`] = `
</View>
</View>
</View>
</View>
</View>
`;
exports[`render unread 1`] = `
@ -592,10 +782,12 @@ exports[`render unread 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -612,8 +804,8 @@ exports[`render unread 1`] = `
Object {
"backgroundColor": "#3F51B5",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -629,7 +821,7 @@ exports[`render unread 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
]
}
@ -642,10 +834,67 @@ exports[`render unread 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -657,44 +906,32 @@ exports[`render unread 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
style={
Object {
"alignItems": "center",
"backgroundColor": "#1d74f5",
"borderRadius": 3,
"borderRadius": 4,
"color": "#fff",
"fontSize": 14,
"minWidth": 20,
"justifyContent": "center",
"minWidth": 25,
"overflow": "hidden",
"paddingHorizontal": 5,
"paddingVertical": 2,
"paddingVertical": 4,
"textAlign": "center",
}
}
@ -704,6 +941,8 @@ exports[`render unread 1`] = `
</View>
</View>
</View>
</View>
</View>
`;
exports[`renders correctly 1`] = `
@ -739,10 +978,12 @@ exports[`renders correctly 1`] = `
style={
Array [
Object {
"alignItems": "center",
"alignItems": "flex-start",
"borderBottomColor": "#ddd",
"borderBottomWidth": 0.5,
"flexDirection": "row",
"paddingHorizontal": 16,
"paddingVertical": 10,
"paddingVertical": 12,
},
undefined,
]
@ -759,8 +1000,8 @@ exports[`renders correctly 1`] = `
Object {
"backgroundColor": "#3F51B5",
"borderRadius": 4,
"height": 40,
"width": 40,
"height": 56,
"width": 56,
},
undefined,
]
@ -776,7 +1017,7 @@ exports[`renders correctly 1`] = `
"color": "#ffffff",
},
Object {
"fontSize": 20,
"fontSize": 28,
},
]
}
@ -789,10 +1030,67 @@ exports[`renders correctly 1`] = `
style={
Object {
"flex": 1,
"height": "100%",
"marginLeft": 16,
"marginRight": 4,
}
}
>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#444",
"flex": 1,
"fontSize": 18,
"fontWeight": "bold",
"marginRight": 8,
}
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"alignItems": "center",
"color": "#888",
"fontSize": 10,
"justifyContent": "center",
}
}
>
Nov 10
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flex": 1,
"flexDirection": "row",
"justifyContent": "center",
"width": "100%",
}
}
>
<Text
accessible={true}
@ -804,31 +1102,19 @@ exports[`renders correctly 1`] = `
Object {
"color": "#444",
"flex": 1,
"flexShrink": 1,
"fontSize": 16,
"marginRight": 8,
},
undefined,
]
}
>
name
</Text>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
numberOfLines={1}
style={
Object {
"color": "#888",
"flex": 1,
"fontSize": 10,
}
}
>
Nov 10
</Text>
</View>
</View>
</View>
</View>
</View>
`;

File diff suppressed because it is too large Load Diff

View File

@ -92,7 +92,7 @@ const RocketChat = {
reduxStore.dispatch(connectFailure());
});
// this.ddp.on('connected', () => this.ddp.subscribe('activeUsers', null, false));
this.ddp.on('connected', () => this.ddp.subscribe('activeUsers', null, false));
this.ddp.on('users', (ddpMessage) => {
if (ddpMessage.collection === 'users') {
@ -128,9 +128,6 @@ const RocketChat = {
const sub = database.objects('subscriptions').filtered('rid == $0', data._id)[0];
database.write(() => {
sub.roomUpdatedAt = data._updatedAt;
if (data.lastMessage) {
// data.lastMessage.url = data.lastMessage.url || [];
}
sub.lastMessage = data.lastMessage;
sub.ro = data.ro;
});
@ -432,9 +429,6 @@ const RocketChat = {
const room = rooms.find(({ _id }) => _id === subscription.rid);
if (room) {
subscription.roomUpdatedAt = room._updatedAt;
// if (room.lastMessage) {
// room.lastMessage.url = room.lastMessage.url || [];
// }
subscription.lastMessage = room.lastMessage;
subscription.ro = room.ro;
}

View File

@ -100,6 +100,7 @@ export default class RoomItem extends React.PureComponent {
static propTypes = {
type: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
StoreLastMessage: PropTypes.bool,
_updatedAt: PropTypes.instanceOf(Date),
lastMessage: PropTypes.object,
favorite: PropTypes.bool,
@ -115,6 +116,18 @@ export default class RoomItem extends React.PureComponent {
return <Avatar text={name} baseUrl={baseUrl} size={56} type={type} />;
}
get lastMessage() {
const {
lastMessage
} = this.props;
if (!this.props.StoreLastMessage) {
return '';
}
return lastMessage ? `${ lastMessage.u.username }: ${ emojify(lastMessage.msg, { output: 'unicode' }) }` : 'No Message';
}
formatDate = date => moment(date).calendar(null, {
lastDay: '[Yesterday]',
sameDay: 'h:mm A',
@ -124,13 +137,11 @@ export default class RoomItem extends React.PureComponent {
render() {
const {
favorite, alert, unread, userMentions, name, lastMessage, _updatedAt
favorite, alert, unread, userMentions, name, _updatedAt
} = this.props;
const date = this.formatDate(_updatedAt);
console.log('do we have a last message?', lastMessage);
let accessibilityLabel = name;
if (unread === 1) {
accessibilityLabel += `, ${ unread } alert`;
@ -154,11 +165,7 @@ export default class RoomItem extends React.PureComponent {
{_updatedAt ? <Text style={styles.update} ellipsizeMode='tail' numberOfLines={1}>{ date }</Text> : null}
</View>
<View style={styles.row}>
<Text style={[styles.lastMessage, alert && styles.alert]} ellipsizeMode='tail' numberOfLines={1}>{!this.props.StoreLastMessage ? '' : lastMessage ? `${ lastMessage.u.username }: ${ emojify(lastMessage.msg, { output: 'unicode' }) }` : 'No Message'}</Text>
<Text style={[styles.lastMessage, alert && styles.alert]} ellipsizeMode='tail' numberOfLines={1}>{this.lastMessage}</Text>
{renderNumber(unread, userMentions)}
</View>
</View>

View File

@ -90,11 +90,11 @@ export default class RoomView extends React.Component {
this.rooms.addListener(this.updateRoom);
}
componentWillReceiveProps(nextProps) {
if (this.props.layoutAnimation !== nextProps.layoutAnimation) {
LayoutAnimation.spring();
}
}
// componentWillReceiveProps(nextProps) {
// // if (this.props.layoutAnimation !== nextProps.layoutAnimation) {
// // LayoutAnimation.spring();
// // }
// }
shouldComponentUpdate(nextProps, nextState) {
return !(equal(this.props, nextProps) && equal(this.state, nextState));
}

View File

@ -3,7 +3,7 @@ import { ListView } from 'realm/react-native';
import React from 'react';
import PropTypes from 'prop-types';
import Icon from 'react-native-vector-icons/Ionicons';
import { Platform, View, TextInput, SafeAreaView } from 'react-native';
import { Platform, View, TextInput, SafeAreaView, LayoutAnimation } from 'react-native';
import { connect } from 'react-redux';
import * as actions from '../../actions';
import * as server from '../../actions/connect';
@ -69,7 +69,9 @@ export default class RoomsListView extends React.Component {
this.search(props.searchText);
}
}
componentWillUpdate() {
LayoutAnimation.easeInEaseOut();
}
componentWillUnmount() {
this.data.removeAllListeners();
}