Merge pull request #1380 from albertgasset/MOBILE-2457

Mobile 2457
main
Juan Leyva 2018-07-04 10:29:31 +02:00 committed by GitHub
commit a16167f186
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -52,6 +52,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
protected keepMessageMap = {};
protected syncObserver: any;
protected oldContentHeight = 0;
protected keyboardObserver: any;
userId: number;
currentUserId: number;
@ -178,6 +179,11 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
this.loaded = true;
});
});
// Recalculate footer position when keyboard is shown or hidden.
this.keyboardObserver = this.eventsProvider.on(CoreEventsProvider.KEYBOARD_CHANGE, (isOn) => {
this.content.resize();
});
}
/**
@ -692,6 +698,7 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
// Unset again, just in case.
this.unsetPolling();
this.syncObserver && this.syncObserver.off();
this.keyboardObserver && this.keyboardObserver.off();
this.viewDestroyed = true;
}
}

View File

@ -15,6 +15,7 @@
import { Component, ViewChild, NgZone } from '@angular/core';
import { Content, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';
import { CoreAppProvider } from '@providers/app';
import { CoreEventsProvider } from '@providers/events';
import { CoreLoggerProvider } from '@providers/logger';
import { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom';
@ -49,12 +50,14 @@ export class AddonModChatChatPage {
protected lastTime = 0;
protected oldContentHeight = 0;
protected onlineObserver: any;
protected keyboardObserver: any;
protected viewDestroyed = false;
protected pollingRunning = false;
constructor(navParams: NavParams, logger: CoreLoggerProvider, network: Network, zone: NgZone, private navCtrl: NavController,
private chatProvider: AddonModChatProvider, private appProvider: CoreAppProvider, sitesProvider: CoreSitesProvider,
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider) {
private modalCtrl: ModalController, private domUtils: CoreDomUtilsProvider, private textUtils: CoreTextUtilsProvider,
private eventsProvider: CoreEventsProvider) {
this.chatId = navParams.get('chatId');
this.courseId = navParams.get('courseId');
@ -87,6 +90,11 @@ export class AddonModChatChatPage {
}).finally(() => {
this.loaded = true;
});
// Recalculate footer position when keyboard is shown or hidden.
this.keyboardObserver = this.eventsProvider.on(CoreEventsProvider.KEYBOARD_CHANGE, (isOn) => {
this.content.resize();
});
}
/**
@ -313,6 +321,7 @@ export class AddonModChatChatPage {
*/
ngOnDestroy(): void {
this.onlineObserver && this.onlineObserver.unsubscribe();
this.keyboardObserver && this.keyboardObserver.off();
this.stopPolling();
this.viewDestroyed = true;
}