Merge branch 'improves' into typing
This commit is contained in:
commit
de25bd3bff
|
@ -63,11 +63,13 @@ const RocketChat = {
|
||||||
|
|
||||||
Meteor.ddp.on('connected', async() => {
|
Meteor.ddp.on('connected', async() => {
|
||||||
Meteor.ddp.on('changed', (ddpMessage) => {
|
Meteor.ddp.on('changed', (ddpMessage) => {
|
||||||
|
const server = { id: reduxStore.getState().server.server };
|
||||||
if (ddpMessage.collection === 'stream-room-messages') {
|
if (ddpMessage.collection === 'stream-room-messages') {
|
||||||
realm.write(() => {
|
realm.write(() => {
|
||||||
const message = ddpMessage.fields.args[0];
|
const message = ddpMessage.fields.args[0];
|
||||||
message.temp = false;
|
message.temp = false;
|
||||||
message._server = { id: reduxStore.getState().server.server };
|
message._server = server;
|
||||||
|
message.attachments = message.attachments || [];
|
||||||
realm.create('messages', message, true);
|
realm.create('messages', message, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -79,14 +81,33 @@ const RocketChat = {
|
||||||
reduxStore.dispatch(typing({ _rid, username: ddpMessage.fields.args[0], typing: ddpMessage.fields.args[1] }));
|
reduxStore.dispatch(typing({ _rid, username: ddpMessage.fields.args[0], typing: ddpMessage.fields.args[1] }));
|
||||||
}
|
}
|
||||||
if (ddpMessage.collection === 'stream-notify-user') {
|
if (ddpMessage.collection === 'stream-notify-user') {
|
||||||
realm.write(() => {
|
const [type, data] = ddpMessage.fields.args;
|
||||||
const data = ddpMessage.fields.args[1];
|
const [, ev] = ddpMessage.fields.eventName.split('/');
|
||||||
data._server = { id: reduxStore.getState().server.server };
|
if (/subscriptions/.test(ev)) {
|
||||||
realm.create('subscriptions', data, true);
|
switch (type) {
|
||||||
});
|
case 'inserted':
|
||||||
|
data._server = server;
|
||||||
|
realm.write(() => {
|
||||||
|
realm.create('subscriptions', data, true);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case 'updated':
|
||||||
|
delete data._updatedAt;
|
||||||
|
realm.write(() => {
|
||||||
|
realm.create('subscriptions', data, true);
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (/rooms/.test(ev) && type === 'updated') {
|
||||||
|
const sub = realm.objects('subscriptions').filtered('rid == $0', data._id)[0];
|
||||||
|
realm.write(() => {
|
||||||
|
sub._updatedAt = data._updatedAt;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
RocketChat.getSettings();
|
RocketChat.getSettings();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
@ -234,6 +255,7 @@ const RocketChat = {
|
||||||
data.messages.forEach((message) => {
|
data.messages.forEach((message) => {
|
||||||
message.temp = false;
|
message.temp = false;
|
||||||
message._server = { id: reduxStore.getState().server.server };
|
message._server = { id: reduxStore.getState().server.server };
|
||||||
|
message.attachments = message.attachments || [];
|
||||||
// write('messages', message);
|
// write('messages', message);
|
||||||
realm.create('messages', message, true);
|
realm.create('messages', message, true);
|
||||||
});
|
});
|
||||||
|
@ -367,7 +389,11 @@ const RocketChat = {
|
||||||
rooms = rooms.update;
|
rooms = rooms.update;
|
||||||
}
|
}
|
||||||
const data = subscriptions.map((subscription) => {
|
const data = subscriptions.map((subscription) => {
|
||||||
subscription._updatedAt = (rooms.find(room => room._id === subscription.rid) || subscription)._updatedAt;
|
const room = rooms.find(({ _id }) => _id === subscription.rid);
|
||||||
|
delete subscription._updatedAt;
|
||||||
|
if (room) {
|
||||||
|
subscription._updatedAt = room._updatedAt;
|
||||||
|
}
|
||||||
subscription._server = { id: server.server };
|
subscription._server = { id: server.server };
|
||||||
return subscription;
|
return subscription;
|
||||||
});
|
});
|
||||||
|
@ -377,6 +403,7 @@ const RocketChat = {
|
||||||
realm.create('subscriptions', subscription, true));
|
realm.create('subscriptions', subscription, true));
|
||||||
});
|
});
|
||||||
Meteor.subscribe('stream-notify-user', `${ login.user.id }/subscriptions-changed`, false);
|
Meteor.subscribe('stream-notify-user', `${ login.user.id }/subscriptions-changed`, false);
|
||||||
|
Meteor.subscribe('stream-notify-user', `${ login.user.id }/rooms-changed`, false);
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
logout({ server }) {
|
logout({ server }) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Text, View, StyleSheet, Button, SafeAreaView } from 'react-native';
|
import { Text, View, StyleSheet, Button, SafeAreaView, Dimensions } from 'react-native';
|
||||||
import { ListView } from 'realm/react-native';
|
import { ListView } from 'realm/react-native';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { bindActionCreators } from 'redux';
|
import { bindActionCreators } from 'redux';
|
||||||
|
@ -193,6 +193,7 @@ export default class RoomView extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const { height } = Dimensions.get('window');
|
||||||
return (
|
return (
|
||||||
<KeyboardView contentContainerStyle={styles.container} keyboardVerticalOffset={64}>
|
<KeyboardView contentContainerStyle={styles.container} keyboardVerticalOffset={64}>
|
||||||
{this.renderBanner()}
|
{this.renderBanner()}
|
||||||
|
@ -200,7 +201,7 @@ export default class RoomView extends React.Component {
|
||||||
<ListView
|
<ListView
|
||||||
enableEmptySections
|
enableEmptySections
|
||||||
style={styles.list}
|
style={styles.list}
|
||||||
onEndReachedThreshold={350}
|
onEndReachedThreshold={height / 2}
|
||||||
renderFooter={this.renderHeader}
|
renderFooter={this.renderHeader}
|
||||||
onEndReached={this.onEndReached}
|
onEndReached={this.onEndReached}
|
||||||
dataSource={this.state.dataSource}
|
dataSource={this.state.dataSource}
|
||||||
|
|
Loading…
Reference in New Issue