From 879792ac11ca8d15d482deca0d24f99bc9e430b3 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 29 Mar 2019 11:05:46 +0100 Subject: [PATCH 1/3] MOBILE-2915 messages: Fix error if push clicked in discs view --- .../messages/components/discussions/discussions.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/addon/messages/components/discussions/discussions.ts b/src/addon/messages/components/discussions/discussions.ts index afb9b5d88..b072b719b 100644 --- a/src/addon/messages/components/discussions/discussions.ts +++ b/src/addon/messages/components/discussions/discussions.ts @@ -92,8 +92,8 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy { discussion.unread = false; // Conversations changed, invalidate them and refresh unread counts. - this.messagesProvider.invalidateConversations(); - this.messagesProvider.refreshUnreadConversationCounts(); + this.messagesProvider.invalidateConversations(this.siteId); + this.messagesProvider.refreshUnreadConversationCounts(this.siteId); } } }, this.siteId); @@ -145,10 +145,10 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy { */ refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise { const promises = []; - promises.push(this.messagesProvider.invalidateDiscussionsCache()); + promises.push(this.messagesProvider.invalidateDiscussionsCache(this.siteId)); if (refreshUnreadCounts) { - promises.push(this.messagesProvider.invalidateUnreadConversationCounts()); + promises.push(this.messagesProvider.invalidateUnreadConversationCounts(this.siteId)); } return this.utils.allPromises(promises).finally(() => { @@ -171,7 +171,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy { const promises = []; - promises.push(this.messagesProvider.getDiscussions().then((discussions) => { + promises.push(this.messagesProvider.getDiscussions(this.siteId).then((discussions) => { // Convert to an array for sorting. const discussionsSorted = []; for (const userId in discussions) { @@ -184,7 +184,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy { }); })); - promises.push(this.messagesProvider.getUnreadConversationCounts()); + promises.push(this.messagesProvider.getUnreadConversationCounts(this.siteId)); return Promise.all(promises).catch((error) => { this.domUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); @@ -216,7 +216,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy { this.loaded = false; this.loadingMessage = this.search.loading; - return this.messagesProvider.searchMessages(query).then((searchResults) => { + return this.messagesProvider.searchMessages(query, undefined, undefined, undefined, this.siteId).then((searchResults) => { this.search.showResults = true; this.search.results = searchResults.messages; }).catch((error) => { From b16eb29ac0ee6685cd34a83252c89080e142ec4e Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 29 Mar 2019 11:07:36 +0100 Subject: [PATCH 2/3] MOBILE-2915 core: Fix redirect to logged out sites --- src/core/login/pages/init/init.ts | 3 ++- src/core/login/pages/reconnect/reconnect.ts | 8 ++------ src/core/login/providers/helper.ts | 12 +++++++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/core/login/pages/init/init.ts b/src/core/login/pages/init/init.ts index 45fb36760..3758d04c3 100644 --- a/src/core/login/pages/init/init.ts +++ b/src/core/login/pages/init/init.ts @@ -55,7 +55,8 @@ export class CoreLoginInitPage { .then((loggedIn) => { if (loggedIn) { - return this.navCtrl.setRoot(redirectData.page, redirectData.params, { animate: false }); + return this.loginHelper.goToSiteInitialPage(this.navCtrl, redirectData.page, redirectData.params, + { animate: false }); } }).catch(() => { // Site doesn't exist. diff --git a/src/core/login/pages/reconnect/reconnect.ts b/src/core/login/pages/reconnect/reconnect.ts index 4b56f7dee..03f17efa8 100644 --- a/src/core/login/pages/reconnect/reconnect.ts +++ b/src/core/login/pages/reconnect/reconnect.ts @@ -146,12 +146,8 @@ export class CoreLoginReconnectPage { // Reset fields so the data is not in the view anymore. this.credForm.controls['password'].reset(); - if (this.pageName) { - // Page defined, go to that page instead of site initial page. - return this.navCtrl.setRoot(this.pageName, this.pageParams); - } else { - return this.loginHelper.goToSiteInitialPage(); - } + // Go to the site initial page. + return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams); }).catch((error) => { // Error, go back to login page. this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true); diff --git a/src/core/login/providers/helper.ts b/src/core/login/providers/helper.ts index bf8abb21b..3d84c5232 100644 --- a/src/core/login/providers/helper.ts +++ b/src/core/login/providers/helper.ts @@ -14,7 +14,7 @@ import { Injectable } from '@angular/core'; import { Location } from '@angular/common'; -import { Platform, AlertController } from 'ionic-angular'; +import { Platform, AlertController, NavController, NavOptions } from 'ionic-angular'; import { TranslateService } from '@ngx-translate/core'; import { CoreAppProvider } from '@providers/app'; import { CoreConfigProvider } from '@providers/config'; @@ -416,14 +416,20 @@ export class CoreLoginHelperProvider { /** * Go to the initial page of a site depending on 'userhomepage' setting. * + * @param {NavController} [navCtrl] NavController to use. Defaults to app root NavController. + * @param {string} [page] Name of the page to load after loading the main page. + * @param {any} [params] Params to pass to the page. + * @param {NavOptions} [options] Navigation options. * @return {Promise} Promise resolved when done. */ - goToSiteInitialPage(): Promise { + goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: any, options?: NavOptions): Promise { + navCtrl = navCtrl || this.appProvider.getRootNavController(); + // Due to DeepLinker, we need to remove the path from the URL before going to main menu. // IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL. this.location.replaceState(''); - return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage'); + return navCtrl.setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params }, options); } /** From ceff8858f4e073e411dbbd0ddc08ab44ef2c3308 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 29 Mar 2019 11:43:25 +0100 Subject: [PATCH 3/3] MOBILE-2915 blog: Always display show my entries toggle --- src/addon/blog/components/entries/entries.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/addon/blog/components/entries/entries.ts b/src/addon/blog/components/entries/entries.ts index 282c6ef87..54f84d30a 100644 --- a/src/addon/blog/components/entries/entries.ts +++ b/src/addon/blog/components/entries/entries.ts @@ -135,9 +135,7 @@ export class AddonBlogEntriesComponent implements OnInit { this.canLoadMore = result.totalentries > this.entries.length; this.pageLoaded++; - this.showMyIssuesToggle = !this.userId && (this.showMyIssuesToggle || this.entries.some((entry) => { - return entry.userid == this.currentUserId; - })); + this.showMyIssuesToggle = !this.userId; return Promise.all(promises); }).catch((message) => {