[FIX] Room subscription issues (#1255)
This commit is contained in:
parent
3ee97881f3
commit
b9485ad3f8
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue