[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 disconnectedListener;
|
||||||
let notifyRoomListener;
|
let notifyRoomListener;
|
||||||
let messageReceivedListener;
|
let messageReceivedListener;
|
||||||
const typingTimeouts = {};
|
|
||||||
|
|
||||||
const handleConnection = () => {
|
const handleConnection = () => {
|
||||||
this.loadMissedMessages({ rid }).catch(e => console.log(e));
|
this.loadMissedMessages({ rid }).catch(e => console.log(e));
|
||||||
|
@ -200,12 +199,6 @@ export default function subscribeRoom({ rid }) {
|
||||||
messageReceivedListener.then(removeListener);
|
messageReceivedListener.then(removeListener);
|
||||||
messageReceivedListener = false;
|
messageReceivedListener = false;
|
||||||
}
|
}
|
||||||
Object.keys(typingTimeouts).forEach((key) => {
|
|
||||||
if (typingTimeouts[key]) {
|
|
||||||
clearTimeout(typingTimeouts[key]);
|
|
||||||
typingTimeouts[key] = null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
reduxStore.dispatch(clearUserTyping());
|
reduxStore.dispatch(clearUserTyping());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -203,6 +203,9 @@ class RoomView extends React.Component {
|
||||||
this.init();
|
this.init();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
if (appState === 'background' && appState !== prevProps.appState) {
|
||||||
|
this.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentWillUnmount() {
|
async componentWillUnmount() {
|
||||||
|
@ -234,9 +237,7 @@ class RoomView extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.sub && this.sub.stop) {
|
this.unsubscribe();
|
||||||
this.sub.stop();
|
|
||||||
}
|
|
||||||
if (this.didFocusListener && this.didFocusListener.remove) {
|
if (this.didFocusListener && this.didFocusListener.remove) {
|
||||||
this.didFocusListener.remove();
|
this.didFocusListener.remove();
|
||||||
}
|
}
|
||||||
|
@ -282,6 +283,7 @@ class RoomView extends React.Component {
|
||||||
this.setLastOpen(null);
|
this.setLastOpen(null);
|
||||||
}
|
}
|
||||||
RocketChat.readMessages(room.rid, newLastOpen).catch(e => console.log(e));
|
RocketChat.readMessages(room.rid, newLastOpen).catch(e => console.log(e));
|
||||||
|
this.unsubscribe();
|
||||||
this.sub = await RocketChat.subscribeRoom(room);
|
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) => {
|
observeRoom = (room) => {
|
||||||
const observable = room.observe();
|
const observable = room.observe();
|
||||||
this.subSubscription = observable
|
this.subSubscription = observable
|
||||||
|
|
|
@ -165,7 +165,7 @@ class RoomsListView extends React.Component {
|
||||||
this.willFocusListener = props.navigation.addListener('willFocus', () => {
|
this.willFocusListener = props.navigation.addListener('willFocus', () => {
|
||||||
// Check if there were changes while not focused (it's set on sCU)
|
// Check if there were changes while not focused (it's set on sCU)
|
||||||
if (this.shouldUpdate) {
|
if (this.shouldUpdate) {
|
||||||
animateNextTransition();
|
// animateNextTransition();
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
this.shouldUpdate = false;
|
this.shouldUpdate = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue