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 keepMessageMap = {};
protected syncObserver: any; protected syncObserver: any;
protected oldContentHeight = 0; protected oldContentHeight = 0;
protected keyboardObserver: any;
userId: number; userId: number;
currentUserId: number; currentUserId: number;
@ -178,6 +179,11 @@ export class AddonMessagesDiscussionPage implements OnDestroy {
this.loaded = true; 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. // Unset again, just in case.
this.unsetPolling(); this.unsetPolling();
this.syncObserver && this.syncObserver.off(); this.syncObserver && this.syncObserver.off();
this.keyboardObserver && this.keyboardObserver.off();
this.viewDestroyed = true; this.viewDestroyed = true;
} }
} }

View File

@ -15,6 +15,7 @@
import { Component, ViewChild, NgZone } from '@angular/core'; import { Component, ViewChild, NgZone } from '@angular/core';
import { Content, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular'; import { Content, IonicPage, ModalController, NavController, NavParams } from 'ionic-angular';
import { CoreAppProvider } from '@providers/app'; import { CoreAppProvider } from '@providers/app';
import { CoreEventsProvider } from '@providers/events';
import { CoreLoggerProvider } from '@providers/logger'; import { CoreLoggerProvider } from '@providers/logger';
import { CoreSitesProvider } from '@providers/sites'; import { CoreSitesProvider } from '@providers/sites';
import { CoreDomUtilsProvider } from '@providers/utils/dom'; import { CoreDomUtilsProvider } from '@providers/utils/dom';
@ -49,12 +50,14 @@ export class AddonModChatChatPage {
protected lastTime = 0; protected lastTime = 0;
protected oldContentHeight = 0; protected oldContentHeight = 0;
protected onlineObserver: any; protected onlineObserver: any;
protected keyboardObserver: any;
protected viewDestroyed = false; protected viewDestroyed = false;
protected pollingRunning = false; protected pollingRunning = false;
constructor(navParams: NavParams, logger: CoreLoggerProvider, network: Network, zone: NgZone, private navCtrl: NavController, constructor(navParams: NavParams, logger: CoreLoggerProvider, network: Network, zone: NgZone, private navCtrl: NavController,
private chatProvider: AddonModChatProvider, private appProvider: CoreAppProvider, sitesProvider: CoreSitesProvider, 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.chatId = navParams.get('chatId');
this.courseId = navParams.get('courseId'); this.courseId = navParams.get('courseId');
@ -87,6 +90,11 @@ export class AddonModChatChatPage {
}).finally(() => { }).finally(() => {
this.loaded = true; 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 { ngOnDestroy(): void {
this.onlineObserver && this.onlineObserver.unsubscribe(); this.onlineObserver && this.onlineObserver.unsubscribe();
this.keyboardObserver && this.keyboardObserver.off();
this.stopPolling(); this.stopPolling();
this.viewDestroyed = true; this.viewDestroyed = true;
} }