Ddp fixes (#324)

This commit is contained in:
Diego Mello 2018-06-12 22:29:18 -03:00 committed by Guilherme Gazzo
parent 6c67179c3a
commit 802eff267c
11 changed files with 988 additions and 918 deletions

View File

@ -3,7 +3,7 @@ import { Provider } from 'react-redux';
import { createStore, combineReducers } from 'redux';
const reducers = combineReducers({login:() => ({user: {}}), settings:() => ({})});
const reducers = combineReducers({login:() => ({user: {}}), settings:() => ({}), meteor: () => ({ connected: true })});
const store = createStore(reducers);
import React from 'react';

View File

@ -3,15 +3,10 @@
exports[`render channel 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="general, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -19,8 +14,6 @@ exports[`render channel 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -175,15 +168,10 @@ exports[`render channel 1`] = `
exports[`render no icon 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="name, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -191,8 +179,6 @@ exports[`render no icon 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -347,15 +333,10 @@ exports[`render no icon 1`] = `
exports[`render private group 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="private-group, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -363,8 +344,6 @@ exports[`render private group 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -520,15 +499,10 @@ exports[`render private group 1`] = `
exports[`render unread +999 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="name, 1000 alerts, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -536,8 +510,6 @@ exports[`render unread +999 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -609,11 +581,6 @@ exports[`render unread +999 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -782,15 +749,10 @@ exports[`render unread +999 1`] = `
exports[`render unread 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="name, 1 alert, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -798,8 +760,6 @@ exports[`render unread 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -871,11 +831,6 @@ exports[`render unread 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -1044,15 +999,10 @@ exports[`render unread 1`] = `
exports[`renders correctly 1`] = `
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="name, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -1060,8 +1010,6 @@ exports[`renders correctly 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -1133,11 +1081,6 @@ exports[`renders correctly 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {

View File

@ -58,11 +58,6 @@ exports[`Storyshots Avatar avatar 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -137,11 +132,6 @@ exports[`Storyshots Avatar avatar 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -216,11 +206,6 @@ exports[`Storyshots Avatar avatar 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -295,11 +280,6 @@ exports[`Storyshots Avatar avatar 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -327,15 +307,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
<RCTScrollView>
<View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="rocket.cat, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -343,8 +318,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -416,11 +389,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -561,15 +529,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="rocket.cat, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -577,8 +540,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -650,11 +611,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -799,15 +755,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="rocket.cat, 1 alert, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -815,8 +766,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -888,11 +837,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -1056,15 +1000,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, 9 alerts, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -1072,8 +1011,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -1145,11 +1082,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -1317,15 +1249,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, 99 alerts, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -1333,8 +1260,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -1406,11 +1331,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -1574,15 +1494,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, 100 alerts, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -1590,8 +1505,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -1663,11 +1576,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -1831,15 +1739,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, 100000 alerts, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -1847,8 +1750,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -1920,11 +1821,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -2088,15 +1984,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, 100000 alerts, you were mentioned, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -2104,8 +1995,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -2177,11 +2066,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -2345,15 +2229,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="W, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -2361,8 +2240,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -2434,11 +2311,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -2579,15 +2451,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel="WW, last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -2595,8 +2462,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -2668,11 +2533,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {
@ -2813,15 +2673,10 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
</View>
</View>
<View
accessibilityComponentType={undefined}
accessibilityLabel=", last message Nov 10"
accessibilityTraits="selected"
accessible={true}
hasTVPreferredFocus={undefined}
hitSlop={undefined}
isTVSelectable={true}
nativeID={undefined}
onLayout={undefined}
onResponderGrant={[Function]}
onResponderMove={[Function]}
onResponderRelease={[Function]}
@ -2829,8 +2684,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
onResponderTerminationRequest={[Function]}
onStartShouldSetResponder={[Function]}
style={null}
testID={undefined}
tvParallaxProperties={undefined}
>
<View
style={
@ -2902,11 +2755,6 @@ exports[`Storyshots Channel Cell Direct Messages 1`] = `
}
>
<FastImageView
onFastImageError={undefined}
onFastImageLoad={undefined}
onFastImageLoadEnd={undefined}
onFastImageLoadStart={undefined}
onFastImageProgress={undefined}
resizeMode="cover"
source={
Object {

View File

@ -1,7 +1,7 @@
import React from 'react';
import { View, StyleSheet, Platform } from 'react-native';
import PropTypes from 'prop-types';
import SafeAreaView from 'react-native-safe-area-view';
import { SafeAreaView } from 'react-navigation';
let platformContainerStyles;
if (Platform.OS === 'ios') {

View File

@ -15,10 +15,6 @@ export const _formatTime = function(seconds) {
};
export default class extends React.PureComponent {
static propTypes = {
onFinish: PropTypes.func.isRequired
}
static async permission() {
if (Platform.OS !== 'android') {
return true;
@ -33,6 +29,10 @@ export default class extends React.PureComponent {
return result === true || result === PermissionsAndroid.RESULTS.GRANTED;
}
static propTypes = {
onFinish: PropTypes.func.isRequired
}
constructor() {
super();

View File

@ -14,27 +14,36 @@ const styles = StyleSheet.create({
@connect(state => ({
activeUsers: state.activeUsers,
user: state.login.user
user: state.login.user,
offline: !state.meteor.connected
}))
export default class Status extends React.Component {
static propTypes = {
style: ViewPropTypes.style,
id: PropTypes.string,
activeUsers: PropTypes.object
activeUsers: PropTypes.object,
user: PropTypes.object,
offline: PropTypes.bool
};
shouldComponentUpdate(nextProps) {
const { id: userId, user } = this.props;
if (user.id === userId) {
if (nextProps.offline !== this.props.offline) {
return true;
}
return (nextProps.user && nextProps.user.status !== user.status);
}
return (nextProps.activeUsers[userId] && nextProps.activeUsers[userId].status) !== this.status;
}
get status() {
const { id: userId, user } = this.props;
const { id: userId, user, offline } = this.props;
if (user.id === userId) {
if (offline) {
return 'offline';
}
return user.status || 'offline';
}
return (this.props.activeUsers && this.props.activeUsers[userId] && this.props.activeUsers[userId].status) || 'offline';

View File

@ -71,14 +71,14 @@ export default class Socket extends EventEmitter {
this.subscriptions = {};
this.ddp = new EventEmitter();
this._logged = false;
const waitTimeout = () => setTimeout(async() => {
const waitTimeout = () => setTimeout(() => {
// this.connection.ping();
this.send({ msg: 'ping' });
this.send({ msg: 'ping' }).catch(e => log('ping', e));
this.timeout = setTimeout(() => this.reconnect(), 1000);
}, 40000);
const handlePing = () => {
this.lastping = new Date();
this.send({ msg: 'pong' }, true);
this.send({ msg: 'pong' }, true).catch(e => log('pong', e));
if (this.timeout) {
clearTimeout(this.timeout);
}
@ -93,10 +93,10 @@ export default class Socket extends EventEmitter {
};
AppState.addEventListener('change', (nextAppState) => {
AppState.addEventListener('change', async(nextAppState) => {
if (this.state && this.state.match(/inactive/) && nextAppState === 'active') {
try {
this.send({ msg: 'ping' }, true);
await this.send({ msg: 'ping' }, true);
// this.connection.ping();
} catch (e) {
this.reconnect();
@ -115,25 +115,21 @@ export default class Socket extends EventEmitter {
this.on('ready', data => this.ddp.emit(data.subs[0], data));
// this.on('error', () => this.reconnect());
this.on('disconnected', debounce(() => this.reconnect(), 300));
this.on('logged', () => this._logged = true);
this.on('logged', () => {
this._logged = true;
Object.keys(this.subscriptions || {}).forEach((key) => {
const { name, params } = this.subscriptions[key];
this.subscriptions[key].unsubscribe();
this.subscribe(name, ...params);
this.subscriptions[key].unsubscribe().catch(e => log('this.on(logged) unsub', e));
this.subscribe(name, ...params).catch(e => log('this.on(logged) sub', e));
});
});
this.on('open', async() => {
this._logged = false;
this.send({ msg: 'connect', version: '1', support: ['1', 'pre2', 'pre1'] });
this.send({ msg: 'connect', version: '1', support: ['1', 'pre2', 'pre1'] }).catch(e => log('this.on(open)', e));
});
try {
this._connect();
} catch (e) {
log('ddp.constructor._connect', e);
}
this._connect().catch(e => log('ddp.constructor._connect', e));
}
check() {
if (!this.lastping) {
@ -159,7 +155,7 @@ export default class Socket extends EventEmitter {
error.reason = 'User or Password incorrect';
error.message = 'User or Password incorrect';
}
this.emit('logginError', error);
this.emit('loginError', error);
return Promise.reject(error);
}
}
@ -201,7 +197,11 @@ export default class Socket extends EventEmitter {
this.lastping = new Date();
this._close();
clearInterval(this.reconnect_timeout);
this.reconnect_timeout = setInterval(() => (!this.connection || this.connection.readyState > 1 || !this.check()) && this.reconnect(), 5000);
this.reconnect_timeout = setInterval(() => {
if (!this.connection || this.connection.readyState > 1 || !this.check()) {
this.reconnect();
}
}, 5000);
this.connection = new WebSocket(`${ this.url }/websocket`, null);
this.connection.onopen = () => {
@ -210,7 +210,9 @@ export default class Socket extends EventEmitter {
this.ddp.emit('open');
return this._login && this.login(this._login);
};
this.connection.onclose = debounce((e) => { console.log('aer'); this.emit('disconnected', e); }, 300);
this.connection.onclose = debounce((e) => {
this.emit('disconnected', e);
}, 300);
this.connection.onmessage = (e) => {
try {
// console.log('received', e.data, e.target.readyState);
@ -225,10 +227,13 @@ export default class Socket extends EventEmitter {
}
logout() {
this._login = null;
return this.call('logout').then(() => this.subscriptions = {});
return this.call('logout')
.catch(e => log('logout', e))
.finally(() => this.subscriptions = {});
}
disconnect() {
this._close();
this._logged = false;
this._login = null;
this.subscriptions = {};
}
@ -236,7 +241,7 @@ export default class Socket extends EventEmitter {
if (this._timer) {
return;
}
delete this.connection;
this._close();
this._logged = false;
this._timer = setTimeout(async() => {

View File

@ -91,10 +91,11 @@ const RocketChat = {
this.activeUsers = this.activeUsers || {};
const { user } = reduxStore.getState().login;
const status = (ddpMessage.fields && ddpMessage.fields.status) || 'offline';
if (user && user.id === ddpMessage.id) {
reduxStore.dispatch(setUser({ status }));
if (!ddpMessage.fields) {
reduxStore.dispatch(setUser({ status: 'offline' }));
}
reduxStore.dispatch(setUser(ddpMessage.fields));
}
if (this._setUserTimer) {
@ -150,7 +151,7 @@ const RocketChat = {
this.ddp.on('login', protectedFunction(() => reduxStore.dispatch(loginRequest())));
this.ddp.on('logginError', protectedFunction(err => reduxStore.dispatch(loginFailure(err))));
this.ddp.on('loginError', protectedFunction(err => reduxStore.dispatch(loginFailure(err))));
this.ddp.on('users', protectedFunction(ddpMessage => RocketChat._setUser(ddpMessage)));

1575
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -24,9 +24,9 @@
},
"dependencies": {
"@remobile/react-native-toast": "^1.0.7",
"@storybook/addons": "^3.4.5",
"@storybook/react-native": "^3.4.5",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"@storybook/addons": "^3.4.7",
"@storybook/react-native": "^3.4.7",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-remove-console": "^6.9.4",
"babel-polyfill": "^6.26.0",
"babel-preset-expo": "^4.0.0",
@ -35,9 +35,9 @@
"js-base64": "^2.4.5",
"lodash": "^4.17.10",
"markdown-it-flowdock": "^0.3.7",
"moment": "^2.22.1",
"moment": "^2.22.2",
"prop-types": "^15.6.1",
"react": "^16.3.2",
"react": "^16.4.0",
"react-clone-referenced-element": "^1.0.1",
"react-emojione": "^5.0.0",
"react-native": "^0.55.4",
@ -53,55 +53,54 @@
"react-native-keyboard-input": "git+https://github.com/RocketChat/react-native-keyboard-input.git",
"react-native-keyboard-tracking-view": "git+https://github.com/RocketChat/react-native-keyboard-tracking-view.git",
"react-native-markdown-renderer": "git+https://github.com/RocketChat/react-native-markdown-renderer.git",
"react-native-meteor": "^1.2.0",
"react-native-modal": "^6.0.0",
"react-native-meteor": "^1.3.0",
"react-native-modal": "^6.1.0",
"react-native-optimized-flatlist": "^1.0.4",
"react-native-push-notification": "^3.0.1",
"react-native-responsive-ui": "^1.1.1",
"react-native-safari-view": "^2.1.0",
"react-native-safe-area-view": "^0.7.0",
"react-native-scrollable-tab-view": "^0.8.0",
"react-native-slider": "^0.11.0",
"react-native-splash-screen": "^3.0.6",
"react-native-svg": "^6.3.1",
"react-native-svg-image": "^2.0.1",
"react-native-vector-icons": "^4.6.0",
"react-native-video": "^2.0.0",
"react-native-video": "^2.2.0",
"react-native-video-controls": "^2.2.1",
"react-native-zeroconf": "^0.8.3",
"react-navigation": "^2.0.0",
"react-navigation": "^2.3.0",
"react-redux": "^5.0.6",
"realm": "^2.6.0",
"realm": "^2.8.2",
"redux": "^4.0.0",
"redux-enhancer-react-native-appstate": "^0.3.1",
"redux-immutable-state-invariant": "^2.1.0",
"redux-saga": "^0.16.0",
"regenerator-runtime": "^0.11.1",
"snyk": "^1.80.1",
"snyk": "^1.82.2",
"strip-ansi": "^4.0.0"
},
"devDependencies": {
"@storybook/addon-storyshots": "^3.4.5",
"@storybook/addon-storyshots": "^3.4.7",
"babel-eslint": "^8.2.3",
"babel-jest": "^22.4.4",
"babel-jest": "^23.0.1",
"babel-plugin-transform-react-remove-prop-types": "^0.4.10",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"codecov": "^3.0.2",
"detox": "^7.3.5",
"detox": "^7.4.2",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react": "^7.9.1",
"eslint-plugin-react-native": "^3.2.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^22.4.4",
"jest-cli": "^22.4.4",
"mocha": "^5.1.1",
"react-dom": "^16.3.2",
"jest": "^23.1.0",
"jest-cli": "^23.1.0",
"mocha": "^5.2.0",
"react-dom": "^16.4.0",
"react-native-bundle-visualizer": "^1.2.0",
"react-test-renderer": "^16.3.2",
"react-test-renderer": "^16.4.0",
"reactotron-react-native": "^1.14.0",
"reactotron-redux": "^1.13.0",
"reactotron-redux-saga": "^1.13.0"

View File

@ -13,7 +13,7 @@ import { storiesOf } from '@storybook/react-native';
import DirectMessage from './Channels/DirectMessage';
import Avatar from './Avatar';
const reducers = combineReducers({ settings: () => ({}), login: () => ({ user: {} }) });
const reducers = combineReducers({ settings: () => ({}), login: () => ({ user: {} }), meteor: () => ({ connected: true }) });
const store = createStore(reducers);
storiesOf('Avatar', module).addDecorator(story => <Provider store={store}>{story()}</Provider>).add('avatar', () => Avatar);