Merge pull request #1826 from dpalou/MOBILE-2915

Mobile 2915
main
Juan Leyva 2019-03-29 12:17:48 +01:00 committed by GitHub
commit 5971969a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 20 deletions

View File

@ -135,9 +135,7 @@ export class AddonBlogEntriesComponent implements OnInit {
this.canLoadMore = result.totalentries > this.entries.length; this.canLoadMore = result.totalentries > this.entries.length;
this.pageLoaded++; this.pageLoaded++;
this.showMyIssuesToggle = !this.userId && (this.showMyIssuesToggle || this.entries.some((entry) => { this.showMyIssuesToggle = !this.userId;
return entry.userid == this.currentUserId;
}));
return Promise.all(promises); return Promise.all(promises);
}).catch((message) => { }).catch((message) => {

View File

@ -92,8 +92,8 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
discussion.unread = false; discussion.unread = false;
// Conversations changed, invalidate them and refresh unread counts. // Conversations changed, invalidate them and refresh unread counts.
this.messagesProvider.invalidateConversations(); this.messagesProvider.invalidateConversations(this.siteId);
this.messagesProvider.refreshUnreadConversationCounts(); this.messagesProvider.refreshUnreadConversationCounts(this.siteId);
} }
} }
}, this.siteId); }, this.siteId);
@ -145,10 +145,10 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
*/ */
refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise<any> { refreshData(refresher?: any, refreshUnreadCounts: boolean = true): Promise<any> {
const promises = []; const promises = [];
promises.push(this.messagesProvider.invalidateDiscussionsCache()); promises.push(this.messagesProvider.invalidateDiscussionsCache(this.siteId));
if (refreshUnreadCounts) { if (refreshUnreadCounts) {
promises.push(this.messagesProvider.invalidateUnreadConversationCounts()); promises.push(this.messagesProvider.invalidateUnreadConversationCounts(this.siteId));
} }
return this.utils.allPromises(promises).finally(() => { return this.utils.allPromises(promises).finally(() => {
@ -171,7 +171,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
const promises = []; const promises = [];
promises.push(this.messagesProvider.getDiscussions().then((discussions) => { promises.push(this.messagesProvider.getDiscussions(this.siteId).then((discussions) => {
// Convert to an array for sorting. // Convert to an array for sorting.
const discussionsSorted = []; const discussionsSorted = [];
for (const userId in discussions) { 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) => { return Promise.all(promises).catch((error) => {
this.domUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true); this.domUtils.showErrorModalDefault(error, 'addon.messages.errorwhileretrievingdiscussions', true);
@ -216,7 +216,7 @@ export class AddonMessagesDiscussionsComponent implements OnDestroy {
this.loaded = false; this.loaded = false;
this.loadingMessage = this.search.loading; 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.showResults = true;
this.search.results = searchResults.messages; this.search.results = searchResults.messages;
}).catch((error) => { }).catch((error) => {

View File

@ -55,7 +55,8 @@ export class CoreLoginInitPage {
.then((loggedIn) => { .then((loggedIn) => {
if (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(() => { }).catch(() => {
// Site doesn't exist. // Site doesn't exist.

View File

@ -146,12 +146,8 @@ export class CoreLoginReconnectPage {
// Reset fields so the data is not in the view anymore. // Reset fields so the data is not in the view anymore.
this.credForm.controls['password'].reset(); this.credForm.controls['password'].reset();
if (this.pageName) { // Go to the site initial page.
// Page defined, go to that page instead of site initial page. return this.loginHelper.goToSiteInitialPage(this.navCtrl, this.pageName, this.pageParams);
return this.navCtrl.setRoot(this.pageName, this.pageParams);
} else {
return this.loginHelper.goToSiteInitialPage();
}
}).catch((error) => { }).catch((error) => {
// Error, go back to login page. // Error, go back to login page.
this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true); this.domUtils.showErrorModalDefault(error, 'core.login.errorupdatesite', true);

View File

@ -14,7 +14,7 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Location } from '@angular/common'; 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 { TranslateService } from '@ngx-translate/core';
import { CoreAppProvider } from '@providers/app'; import { CoreAppProvider } from '@providers/app';
import { CoreConfigProvider } from '@providers/config'; import { CoreConfigProvider } from '@providers/config';
@ -416,14 +416,20 @@ export class CoreLoginHelperProvider {
/** /**
* Go to the initial page of a site depending on 'userhomepage' setting. * 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<any>} Promise resolved when done. * @return {Promise<any>} Promise resolved when done.
*/ */
goToSiteInitialPage(): Promise<any> { goToSiteInitialPage(navCtrl?: NavController, page?: string, params?: any, options?: NavOptions): Promise<any> {
navCtrl = navCtrl || this.appProvider.getRootNavController();
// Due to DeepLinker, we need to remove the path from the URL before going to main menu. // 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. // IonTabs checks the URL to determine which path to load for deep linking, so we clear the URL.
this.location.replaceState(''); this.location.replaceState('');
return this.appProvider.getRootNavController().setRoot('CoreMainMenuPage'); return navCtrl.setRoot('CoreMainMenuPage', { redirectPage: page, redirectParams: params }, options);
} }
/** /**