[FIX] Messages stop loading (#1410)

This commit is contained in:
Diego Mello 2019-11-21 16:10:55 -03:00 committed by GitHub
parent e5791215a4
commit 4ace446334
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -71,6 +71,7 @@ export class List extends React.Component {
.observeWithColumns(['_updated_at']);
}
this.unsubscribeMessages();
this.messagesSubscription = this.messagesObservable
.subscribe((data) => {
this.interaction = InteractionManager.runAfterInteractions(() => {
@ -109,9 +110,7 @@ export class List extends React.Component {
}
componentWillUnmount() {
if (this.messagesSubscription && this.messagesSubscription.unsubscribe) {
this.messagesSubscription.unsubscribe();
}
this.unsubscribeMessages();
if (this.interaction && this.interaction.cancel) {
this.interaction.cancel();
}
@ -161,6 +160,12 @@ export class List extends React.Component {
this.update();
}, 300)
unsubscribeMessages = () => {
if (this.messagesSubscription && this.messagesSubscription.unsubscribe) {
this.messagesSubscription.unsubscribe();
}
}
renderFooter = () => {
const { loading } = this.state;
if (loading) {

View File

@ -202,6 +202,10 @@ class RoomView extends React.Component {
if (appState === 'foreground' && appState !== prevProps.appState) {
this.onForegroundInteraction = InteractionManager.runAfterInteractions(() => {
this.init();
// Fire List.init() just to keep observables working
if (this.list && this.list.current) {
this.list.current.init();
}
});
}
if (appState === 'background' && appState !== prevProps.appState) {