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

View File

@ -202,6 +202,10 @@ class RoomView extends React.Component {
if (appState === 'foreground' && appState !== prevProps.appState) { if (appState === 'foreground' && appState !== prevProps.appState) {
this.onForegroundInteraction = InteractionManager.runAfterInteractions(() => { this.onForegroundInteraction = InteractionManager.runAfterInteractions(() => {
this.init(); 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) { if (appState === 'background' && appState !== prevProps.appState) {