fix last messages (#239)

* fix last messages
This commit is contained in:
Guilherme Gazzo 2018-02-19 16:15:31 -05:00 committed by GitHub
parent 3e0ade1fdb
commit bb5e29fdc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7738 additions and 3633 deletions

View File

@ -222,6 +222,10 @@ workflows:
only:
- develop
- master
# - ios-testflight:
# requires:
# - ios-hold-testflight
- android-build:
requires:
- lint-testunit

View File

@ -11,7 +11,6 @@
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects

View File

@ -21,6 +21,15 @@ const call = (method, ...params) => RocketChat.ddp.call(method, ...params); // e
const TOKEN_KEY = 'reactnativemeteor_usertoken';
const SERVER_TIMEOUT = 30000;
const normalizeMessage = (lastMessage) => {
if (lastMessage) {
lastMessage.attachments = lastMessage.attachments || [];
}
return lastMessage;
};
const RocketChat = {
TOKEN_KEY,
@ -128,9 +137,10 @@ const RocketChat = {
}
if (/rooms/.test(ev) && type === 'updated') {
const sub = database.objects('subscriptions').filtered('rid == $0', data._id)[0];
database.write(() => {
sub.roomUpdatedAt = data._updatedAt;
sub.lastMessage = data.lastMessage;
sub.lastMessage = normalizeMessage(data.lastMessage);
sub.ro = data.ro;
});
}
@ -261,7 +271,7 @@ const RocketChat = {
},
_buildMessage(message) {
message.status = messagesStatus.SENT;
message.attachments = message.attachments || [];
normalizeMessage(message);
if (message.urls) {
message.urls = RocketChat._parseUrls(message.urls);
}
@ -431,7 +441,7 @@ const RocketChat = {
const room = rooms.find(({ _id }) => _id === subscription.rid);
if (room) {
subscription.roomUpdatedAt = room._updatedAt;
subscription.lastMessage = room.lastMessage;
subscription.lastMessage = normalizeMessage(room.lastMessage);
subscription.ro = room.ro;
}
if (subscription.roles) {

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, FlatList } from 'react-native';
import { connect } from 'react-redux';
import * as actions from '../../actions';
import * as server from '../../actions/connect';
@ -49,6 +49,7 @@ export default class RoomsListView extends React.Component {
dataSource: ds.cloneWithRows([]),
searchText: ''
};
this._keyExtractor = this._keyExtractor.bind(this);
this.data = database.objects('subscriptions').sorted('roomUpdatedAt', true);
}
@ -62,6 +63,10 @@ export default class RoomsListView extends React.Component {
this.updateState();
}
// shouldComponentUpdate() {
// return false;
// }
componentWillReceiveProps(props) {
if (this.props.server !== props.server) {
this.data.removeListener(this.updateState);
@ -85,7 +90,6 @@ export default class RoomsListView extends React.Component {
getLastMessage = (subscription) => {
const [room] = database.objects('rooms').filtered('_id = $0', subscription.rid).slice();
console.log('ROOM', room);
return room && room.lastMessage;
}
@ -147,6 +151,7 @@ export default class RoomsListView extends React.Component {
this.setState({
dataSource: ds.cloneWithRows(this.data)
});
// this.forceUpdate();
};
_onPressItem = (item = {}) => {
@ -192,6 +197,10 @@ export default class RoomsListView extends React.Component {
this.props.navigation.navigate('SelectUsers');
}
_keyExtractor(item) {
return item.rid.replace(this.props.user.id, '').trim();
}
renderSearchBar = () => (
<View style={styles.searchBoxView}>
<TextInput
@ -207,7 +216,7 @@ export default class RoomsListView extends React.Component {
</View>
);
renderItem = (item) => {
renderItem = ({ item }) => {
const id = item.rid.replace(this.props.user.id, '').trim();
return (<RoomItem
alert={item.alert}
@ -226,10 +235,12 @@ export default class RoomsListView extends React.Component {
}
renderList = () => (
<ListView
<FlatList
data={this.data}
keyExtractor={this._keyExtractor}
dataSource={this.state.dataSource}
style={styles.list}
renderRow={this.renderItem}
renderItem={this.renderItem}
renderHeader={Platform.OS === 'ios' ? this.renderSearchBar : null}
contentOffset={Platform.OS === 'ios' ? { x: 0, y: 38 } : {}}
enableEmptySections

View File

@ -5,6 +5,7 @@
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; };
00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; };
@ -26,6 +27,7 @@
146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; };
24A2AEF2383D44B586D31C01 /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 06BB44DD4855498082A744AD /* libz.tbd */; };
2684481F67844BE398381564 /* Octicons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = F88C6541BD764BEEABB87272 /* Octicons.ttf */; };
2C800DF680F8451599E80AF1 /* libSafariViewManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D3BB00B9ABF44EA9BD71318 /* libSafariViewManager.a */; };
2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
@ -63,7 +65,6 @@
CBD0E0A35B174C4DBFED3B31 /* Zocial.ttf in Resources */ = {isa = PBXBuildFile; fileRef = E528DE3A405E43B4A37ABA68 /* Zocial.ttf */; };
D6408D9E4A864FF6BA986857 /* SimpleLineIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 8A2DD67ADD954AD9873F45FC /* SimpleLineIcons.ttf */; };
EF736EF520A64AE8820E684A /* libRealmReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DF26CC845883492D8AC8869B /* libRealmReact.a */; };
2C800DF680F8451599E80AF1 /* libSafariViewManager.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D3BB00B9ABF44EA9BD71318 /* libSafariViewManager.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -333,6 +334,13 @@
remoteGlobalIDString = 58B5119B1A9E6C1200147676;
remoteInfo = RCTText;
};
B810DF90203B10490010C331 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 4019A5E1911B4C61944FBCEC /* SafariViewManager.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 134814201AA4EA6300B7C361;
remoteInfo = SafariViewManager;
};
B88F58451FBF55E200B352B8 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = B88F58361FBF55E200B352B8 /* RCTPushNotification.xcodeproj */;
@ -434,6 +442,7 @@
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = RocketChatRN/main.m; sourceTree = "<group>"; };
146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = "../node_modules/react-native/React/React.xcodeproj"; sourceTree = "<group>"; };
1B0746E708284151B8AD1198 /* Ionicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = file; name = Ionicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Ionicons.ttf"; sourceTree = "<group>"; };
1D3BB00B9ABF44EA9BD71318 /* libSafariViewManager.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libSafariViewManager.a; sourceTree = "<group>"; };
20CE3E407E0D4D9E8C9885F2 /* libRCTVideo.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRCTVideo.a; sourceTree = "<group>"; };
22A8B76C8EBA443BB97CE82D /* RNVectorIcons.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNVectorIcons.xcodeproj; path = "../node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj"; sourceTree = "<group>"; };
2D02E47B1E0B4A5D006451C7 /* RocketChatRN-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "RocketChatRN-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -442,6 +451,7 @@
2F5CA2CDA66D46E99B8C184A /* MaterialIcons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = MaterialIcons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/MaterialIcons.ttf"; sourceTree = "<group>"; };
30FCE1B6376C423E94C9FBB0 /* SplashScreen.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = SplashScreen.xcodeproj; path = "../node_modules/react-native-splash-screen/ios/SplashScreen.xcodeproj"; sourceTree = "<group>"; };
3B696712EE2345A59F007A88 /* libRNImagePicker.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRNImagePicker.a; sourceTree = "<group>"; };
4019A5E1911B4C61944FBCEC /* SafariViewManager.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = SafariViewManager.xcodeproj; path = "../node_modules/react-native-safari-view/SafariViewManager.xcodeproj"; sourceTree = "<group>"; };
41FE03CD3B554249859F01BA /* RNZeroconf.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNZeroconf.xcodeproj; path = "../node_modules/react-native-zeroconf/ios/RNZeroconf.xcodeproj"; sourceTree = "<group>"; };
4B38C7E37A8748E0BC665078 /* RNImagePicker.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNImagePicker.xcodeproj; path = "../node_modules/react-native-image-picker/ios/RNImagePicker.xcodeproj"; sourceTree = "<group>"; };
4CD38E4891ED4601B7481448 /* RNFetchBlob.xcodeproj */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = "wrapper.pb-project"; name = RNFetchBlob.xcodeproj; path = "../node_modules/react-native-fetch-blob/ios/RNFetchBlob.xcodeproj"; sourceTree = "<group>"; };
@ -470,8 +480,6 @@
DF26CC845883492D8AC8869B /* libRealmReact.a */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = archive.ar; path = libRealmReact.a; sourceTree = "<group>"; };
E528DE3A405E43B4A37ABA68 /* Zocial.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Zocial.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Zocial.ttf"; sourceTree = "<group>"; };
F88C6541BD764BEEABB87272 /* Octicons.ttf */ = {isa = PBXFileReference; explicitFileType = undefined; fileEncoding = 9; includeInIndex = 0; lastKnownFileType = unknown; name = Octicons.ttf; path = "../node_modules/react-native-vector-icons/Fonts/Octicons.ttf"; sourceTree = "<group>"; };
4019A5E1911B4C61944FBCEC /* SafariViewManager.xcodeproj */ = {isa = PBXFileReference; name = "SafariViewManager.xcodeproj"; path = "../node_modules/react-native-safari-view/SafariViewManager.xcodeproj"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = wrapper.pb-project; explicitFileType = undefined; includeInIndex = 0; };
1D3BB00B9ABF44EA9BD71318 /* libSafariViewManager.a */ = {isa = PBXFileReference; name = "libSafariViewManager.a"; path = "libSafariViewManager.a"; sourceTree = "<group>"; fileEncoding = undefined; lastKnownFileType = archive.ar; explicitFileType = undefined; includeInIndex = 0; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -805,6 +813,14 @@
name = Resources;
sourceTree = "<group>";
};
B810DF8D203B10480010C331 /* Products */ = {
isa = PBXGroup;
children = (
B810DF91203B10490010C331 /* libSafariViewManager.a */,
);
name = Products;
sourceTree = "<group>";
};
B88F58371FBF55E200B352B8 /* Products */ = {
isa = PBXGroup;
children = (
@ -833,6 +849,7 @@
3B696712EE2345A59F007A88 /* libRNImagePicker.a */,
20CE3E407E0D4D9E8C9885F2 /* libRCTVideo.a */,
B2607FA180F14E6584301101 /* libSplashScreen.a */,
1D3BB00B9ABF44EA9BD71318 /* libSafariViewManager.a */,
);
name = "Recovered References";
sourceTree = "<group>";
@ -1078,6 +1095,10 @@
ProductGroup = 607C68741F36522C0096975F /* Products */;
ProjectRef = 41FE03CD3B554249859F01BA /* RNZeroconf.xcodeproj */;
},
{
ProductGroup = B810DF8D203B10480010C331 /* Products */;
ProjectRef = 4019A5E1911B4C61944FBCEC /* SafariViewManager.xcodeproj */;
},
{
ProductGroup = 7ADCFEBC1FEA8A7900763ED8 /* Products */;
ProjectRef = 30FCE1B6376C423E94C9FBB0 /* SplashScreen.xcodeproj */;
@ -1346,6 +1367,13 @@
remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
B810DF91203B10490010C331 /* libSafariViewManager.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = libSafariViewManager.a;
remoteRef = B810DF90203B10490010C331 /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
B88F58461FBF55E200B352B8 /* libRCTPushNotification.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;

6455
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,8 @@
"android": "react-native run-android",
"storybook": "storybook start -p 7007",
"snyk-protect": "snyk protect",
"prepare": "exit 0"
"prepare": "exit 0",
"postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
},
"rnpm": {
"assets": [

4817
yarn.lock

File diff suppressed because it is too large Load Diff