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-content pullingText="{{ 'core.pulltorefresh' | translate }}"></ion-refresher-content>
|
||||||
</ion-refresher>
|
</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-loading [hideUntil]="loaded" [message]="loadingMessage">
|
||||||
<core-empty-box *ngIf="!hasContacts && searchString == ''" icon="person" [message]="'addon.messages.contactlistempty' | translate"></core-empty-box>
|
<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;
|
showDelete = false;
|
||||||
canDelete = false;
|
canDelete = false;
|
||||||
scrollBottom = true;
|
scrollBottom = true;
|
||||||
|
viewDestroyed = false;
|
||||||
|
|
||||||
constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, navParams: NavParams,
|
constructor(private eventsProvider: CoreEventsProvider, sitesProvider: CoreSitesProvider, navParams: NavParams,
|
||||||
private userProvider: CoreUserProvider, private navCtrl: NavController, private messagesSync: AddonMessagesSyncProvider,
|
private userProvider: CoreUserProvider, private navCtrl: NavController, private messagesSync: AddonMessagesSyncProvider,
|
||||||
|
@ -220,6 +221,10 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
return this.getDiscussion(this.pagesLoaded);
|
return this.getDiscussion(this.pagesLoaded);
|
||||||
}).then((messages) => {
|
}).then((messages) => {
|
||||||
|
if (this.viewDestroyed) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we are at the bottom to scroll it after render.
|
// Check if we are at the bottom to scroll it after render.
|
||||||
this.scrollBottom = this.content.scrollHeight - this.content.scrollTop === this.content.contentHeight;
|
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.
|
// Wait for new content height to be calculated.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// Visible content size changed, maintain the bottom position.
|
// 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) {
|
if (!top) {
|
||||||
top = this.content.getContentDimensions().scrollTop;
|
top = this.content.getContentDimensions().scrollTop;
|
||||||
}
|
}
|
||||||
|
@ -579,7 +584,9 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
if (this.scrollBottom) {
|
if (this.scrollBottom) {
|
||||||
// Need a timeout to leave time to the view to be rendered.
|
// Need a timeout to leave time to the view to be rendered.
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.content.scrollToBottom(0);
|
if (!this.viewDestroyed) {
|
||||||
|
this.content.scrollToBottom(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.scrollBottom = false;
|
this.scrollBottom = false;
|
||||||
}
|
}
|
||||||
|
@ -685,5 +692,6 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
|
||||||
// Unset again, just in case.
|
// Unset again, just in case.
|
||||||
this.unsetPolling();
|
this.unsetPolling();
|
||||||
this.syncObserver && this.syncObserver.off();
|
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() showClear = true; // Show/hide clear button.
|
||||||
@Input() disabled = false; // Disables the input text.
|
@Input() disabled = false; // Disables the input text.
|
||||||
@Output() onSubmit: EventEmitter<string>; // Send data when submitting the search form.
|
@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;
|
searched = false;
|
||||||
searchText = '';
|
searchText = '';
|
||||||
|
|
Loading…
Reference in New Issue