MOBILE-2347 messages: Fix scrolling errors on message discussions
parent
3b7c55e23d
commit
604d0e9d9e
|
@ -3,7 +3,7 @@
|
|||
<ion-refresher-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||
</ion-refresher>
|
||||
|
||||
<core-search-box (onSubmit)="search($event)" (onClear])="clearSearch($event)" [placeholder]=" 'addon.messages.contactname' | translate" autocorrect="off" spellcheck="false" lengthCheck="2" [disabled]="!loaded"></core-search-box>
|
||||
<core-search-box (onSubmit)="search($event)" (onClear)="clearSearch($event)" [placeholder]=" 'addon.messages.contactname' | translate" autocorrect="off" spellcheck="false" lengthCheck="2" [disabled]="!loaded"></core-search-box>
|
||||
|
||||
<core-loading [hideUntil]="loaded" [message]="loadingMessage">
|
||||
<core-empty-box *ngIf="!hasContacts && searchString == ''" icon="person" [message]="'addon.messages.contactlistempty' | translate"></core-empty-box>
|
||||
|
|
|
@ -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(() => {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<string>; // Send data when submitting the search form.
|
||||
@Output() onClear?: EventEmitter<void>; // Send event when clearing the search form.
|
||||
@Output() onClear: EventEmitter<void>; // Send event when clearing the search form.
|
||||
|
||||
searched = false;
|
||||
searchText = '';
|
||||
|
|
Loading…
Reference in New Issue