diff --git a/app/lib/methods/subscriptions/room.js b/app/lib/methods/subscriptions/room.js index bbab25b58..1a3de160b 100644 --- a/app/lib/methods/subscriptions/room.js +++ b/app/lib/methods/subscriptions/room.js @@ -19,7 +19,6 @@ export default function subscribeRoom({ rid }) { let disconnectedListener; let notifyRoomListener; let messageReceivedListener; - const typingTimeouts = {}; const handleConnection = () => { this.loadMissedMessages({ rid }).catch(e => console.log(e)); @@ -200,12 +199,6 @@ export default function subscribeRoom({ rid }) { messageReceivedListener.then(removeListener); messageReceivedListener = false; } - Object.keys(typingTimeouts).forEach((key) => { - if (typingTimeouts[key]) { - clearTimeout(typingTimeouts[key]); - typingTimeouts[key] = null; - } - }); reduxStore.dispatch(clearUserTyping()); }; diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index aadbe18ea..7bfe4e5c6 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -203,6 +203,9 @@ class RoomView extends React.Component { this.init(); }); } + if (appState === 'background' && appState !== prevProps.appState) { + this.unsubscribe(); + } } async componentWillUnmount() { @@ -234,9 +237,7 @@ class RoomView extends React.Component { } } } - if (this.sub && this.sub.stop) { - this.sub.stop(); - } + this.unsubscribe(); if (this.didFocusListener && this.didFocusListener.remove) { this.didFocusListener.remove(); } @@ -282,6 +283,7 @@ class RoomView extends React.Component { this.setLastOpen(null); } RocketChat.readMessages(room.rid, newLastOpen).catch(e => console.log(e)); + this.unsubscribe(); this.sub = await RocketChat.subscribeRoom(room); } } @@ -324,6 +326,12 @@ class RoomView extends React.Component { } } + unsubscribe = () => { + if (this.sub && this.sub.stop) { + this.sub.stop(); + } + } + observeRoom = (room) => { const observable = room.observe(); this.subSubscription = observable diff --git a/app/views/RoomsListView/index.js b/app/views/RoomsListView/index.js index ef96f10b7..2f60cbc66 100644 --- a/app/views/RoomsListView/index.js +++ b/app/views/RoomsListView/index.js @@ -165,7 +165,7 @@ class RoomsListView extends React.Component { this.willFocusListener = props.navigation.addListener('willFocus', () => { // Check if there were changes while not focused (it's set on sCU) if (this.shouldUpdate) { - animateNextTransition(); + // animateNextTransition(); this.forceUpdate(); this.shouldUpdate = false; }