From 79b67560ae7fa3a5e65540916feb7bcb1ed707e8 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Wed, 2 Jan 2019 16:37:45 +0100 Subject: [PATCH] MOBILE-2630 messages: Fix PTR issue in conversations --- .../group-conversations.html | 14 +++++----- .../group-conversations.ts | 28 +++++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/addon/messages/pages/group-conversations/group-conversations.html b/src/addon/messages/pages/group-conversations/group-conversations.html index f455f8428..e4d916c38 100644 --- a/src/addon/messages/pages/group-conversations/group-conversations.html +++ b/src/addon/messages/pages/group-conversations/group-conversations.html @@ -15,7 +15,7 @@ - + @@ -33,11 +33,11 @@ {{ 'core.favourites' | translate }} ({{ favourites.count }}) {{ favourites.unread }} -
+
- +

{{ 'addon.messages.nofavourites' | translate }}

@@ -52,11 +52,11 @@ {{ 'addon.messages.groupconversations' | translate }} ({{ group.count }}) {{ group.unread }} -
+
- +

{{ 'addon.messages.nogroupconversations' | translate }}

@@ -70,11 +70,11 @@ {{ 'addon.messages.individualconversations' | translate }} ({{ individual.count }}) {{ individual.unread }} -
+
- +

{{ 'addon.messages.noindividualconversations' | translate }}

diff --git a/src/addon/messages/pages/group-conversations/group-conversations.ts b/src/addon/messages/pages/group-conversations/group-conversations.ts index acfa047f7..39be42305 100644 --- a/src/addon/messages/pages/group-conversations/group-conversations.ts +++ b/src/addon/messages/pages/group-conversations/group-conversations.ts @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core'; +import { Component, OnInit, OnDestroy, ViewChild, ElementRef } from '@angular/core'; import { IonicPage, Platform, NavController, NavParams, Content } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreEventsProvider } from '@providers/events'; @@ -36,6 +36,9 @@ import { CoreUserProvider } from '@core/user/providers/user'; export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { @ViewChild(CoreSplitViewComponent) splitviewCtrl: CoreSplitViewComponent; @ViewChild(Content) content: Content; + @ViewChild('favlist') favListEl: ElementRef; + @ViewChild('grouplist') groupListEl: ElementRef; + @ViewChild('indlist') indListEl: ElementRef; loaded = false; loadingMessage: string; @@ -61,6 +64,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { unread: 0 }; typeIndividual = AddonMessagesProvider.MESSAGE_CONVERSATION_TYPE_INDIVIDUAL; + currentListEl: HTMLElement; protected loadingString: string; protected siteId: string; @@ -295,6 +299,8 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { this.favourites.expanded = this.favourites.count != 0; this.group.expanded = this.favourites.count == 0 && this.group.count != 0; this.individual.expanded = this.favourites.count == 0 && this.group.count == 0; + + this.loadCurrentListElement(); } /** @@ -622,6 +628,7 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { if (option.expanded) { // Already expanded, close it. option.expanded = false; + this.loadCurrentListElement(); } else { this.expandOption(option).catch((error) => { this.domUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); @@ -645,7 +652,9 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { option.expanded = true; option.loading = true; - return this.fetchDataForOption(option, false, refreshUnreadCounts).catch((error) => { + return this.fetchDataForOption(option, false, refreshUnreadCounts).then(() => { + this.loadCurrentListElement(); + }).catch((error) => { option.expanded = false; return Promise.reject(error); @@ -654,6 +663,21 @@ export class AddonMessagesGroupConversationsPage implements OnInit, OnDestroy { }); } + /** + * Load the current list element based on the expanded list. + */ + protected loadCurrentListElement(): void { + if (this.favourites.expanded) { + this.currentListEl = this.favListEl && this.favListEl.nativeElement; + } else if (this.group.expanded) { + this.currentListEl = this.groupListEl && this.groupListEl.nativeElement; + } else if (this.individual.expanded) { + this.currentListEl = this.indListEl && this.indListEl.nativeElement; + } else { + this.currentListEl = undefined; + } + } + /** * Navigate to the search page. */