diff --git a/src/addon/messages/components/contacts/contacts.html b/src/addon/messages/components/contacts/contacts.html index a722ca171..06123d70c 100644 --- a/src/addon/messages/components/contacts/contacts.html +++ b/src/addon/messages/components/contacts/contacts.html @@ -3,7 +3,7 @@ - + diff --git a/src/addon/messages/pages/discussion/discussion.ts b/src/addon/messages/pages/discussion/discussion.ts index f164273f8..d29d7b0ea 100644 --- a/src/addon/messages/pages/discussion/discussion.ts +++ b/src/addon/messages/pages/discussion/discussion.ts @@ -65,6 +65,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy { showDelete = false; canDelete = false; scrollBottom = true; + viewDestroyed = false; constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, navParams: NavParams, private userProvider: CoreUserProvider, private navCtrl: NavController, private messagesSync: AddonMessagesSyncProvider, @@ -220,6 +221,10 @@ export class AddonMessagesDiscussionPage implements OnDestroy { }).then(() => { return this.getDiscussion(this.pagesLoaded); }).then((messages) => { + if (this.viewDestroyed) { + return Promise.resolve(); + } + // Check if we are at the bottom to scroll it after render. this.scrollBottom = this.content.scrollHeight - this.content.scrollTop === this.content.contentHeight; @@ -558,7 +563,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy { // Wait for new content height to be calculated. setTimeout(() => { // Visible content size changed, maintain the bottom position. - if (this.content && this.content.contentHeight != this.oldContentHeight) { + if (!this.viewDestroyed && this.content && this.content.contentHeight != this.oldContentHeight) { if (!top) { top = this.content.getContentDimensions().scrollTop; } @@ -579,7 +584,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy { if (this.scrollBottom) { // Need a timeout to leave time to the view to be rendered. setTimeout(() => { - this.content.scrollToBottom(0); + if (!this.viewDestroyed) { + this.content.scrollToBottom(0); + } }); this.scrollBottom = false; } @@ -685,5 +692,6 @@ export class AddonMessagesDiscussionPage implements OnDestroy { // Unset again, just in case. this.unsetPolling(); this.syncObserver && this.syncObserver.off(); + this.viewDestroyed = true; } } diff --git a/src/components/search-box/search-box.ts b/src/components/search-box/search-box.ts index dabae223c..2e2e9a117 100644 --- a/src/components/search-box/search-box.ts +++ b/src/components/search-box/search-box.ts @@ -40,7 +40,7 @@ export class CoreSearchBoxComponent implements OnInit { @Input() showClear = true; // Show/hide clear button. @Input() disabled = false; // Disables the input text. @Output() onSubmit: EventEmitter; // Send data when submitting the search form. - @Output() onClear?: EventEmitter; // Send event when clearing the search form. + @Output() onClear: EventEmitter; // Send event when clearing the search form. searched = false; searchText = '';