Unverified Commit b9485ad3 authored by Diego Mello's avatar Diego Mello Committed by GitHub
Browse files

[FIX] Room subscription issues (#1255)

parent 3ee97881
......@@ -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());
};
......
......@@ -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
......
......@@ -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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment