MOBILE-3320 navigation: Remove path tracking

main
Noel De Martin 2021-06-10 14:53:53 +02:00
parent b396bfdf6f
commit e2987a44b7
5 changed files with 8 additions and 32 deletions

View File

@ -158,15 +158,13 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
* Setup code for the page.
*/
async ngOnInit(): Promise<void> {
// Disable the profile button if we're already coming from a profile.
const backViewPage = CoreNavigator.getPreviousPath();
this.showInfo = !backViewPage || !CoreTextUtils.matchesGlob(backViewPage, '**/user/profile');
this.route.queryParams.subscribe(async (params) => {
const oldConversationId = this.conversationId;
const oldUserId = this.userId;
this.conversationId = CoreNavigator.getRouteNumberParam('conversationId', { params }) || undefined;
this.userId = CoreNavigator.getRouteNumberParam('userId', { params }) || undefined;
this.showInfo = !params.hideInfo;
if (oldConversationId != this.conversationId || oldUserId != this.userId) {
// Showing reload again can break animations.

View File

@ -77,6 +77,7 @@ export class AddonMessagesSendMessageUserHandlerService implements CoreUserProfi
const pageParams: Params = {
showKeyboard: true,
userId: user.id,
hideInfo: true,
};
CoreNavigator.navigateToSitePath('/messages/discussion', { params: pageParams });
},

View File

@ -361,6 +361,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
{
params: {
preview,
fromIndex: true,
},
},
);

View File

@ -61,6 +61,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
title?: string;
preview = false;
fromIndex = false;
cmId!: number;
courseId!: number;
feedback?: AddonModFeedbackWSFeedback;
@ -96,6 +97,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
this.currentPage = CoreNavigator.getRouteNumberParam('page');
this.title = CoreNavigator.getRouteParam('title');
this.preview = !!CoreNavigator.getRouteBooleanParam('preview');
this.fromIndex = !!CoreNavigator.getRouteBooleanParam('fromIndex');
await this.fetchData();
@ -373,10 +375,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
* Function to link implemented features.
*/
showAnalysis(): void {
const indexPath = AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`;
const previousPath = CoreNavigator.getPreviousPath();
if (previousPath.match(new RegExp(indexPath + '$'))) {
if (this.fromIndex) {
// Previous page is the index page, go back.
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
feedbackId: this.feedback!.id,
@ -389,7 +388,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
return;
}
CoreNavigator.navigateToSitePath(indexPath, {
CoreNavigator.navigateToSitePath(AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
params: {
module: this.module,
tab: 'analysis',

View File

@ -13,7 +13,7 @@
// limitations under the License.
import { Injectable } from '@angular/core';
import { ActivatedRoute, NavigationStart, Params, Router as RouterService } from '@angular/router';
import { ActivatedRoute, Params } from '@angular/router';
import { NavigationOptions } from '@ionic/angular/providers/nav-controller';
@ -28,7 +28,6 @@ import { CoreUrlUtils } from '@services/utils/url';
import { CoreTextUtils } from '@services/utils/text';
import { makeSingleton, NavController, Router } from '@singletons';
import { CoreScreen } from './screen';
import { filter } from 'rxjs/operators';
import { CoreApp } from './app';
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
@ -75,17 +74,6 @@ export class CoreNavigatorService {
protected storedParams: Record<number, unknown> = {};
protected lastParamId = 0;
protected currentPath?: string;
protected previousPath?: string;
// @todo Param router is an optional param to let the mocking work.
constructor(router?: RouterService) {
router?.events.pipe(filter(event => event instanceof NavigationStart)).subscribe((routerEvent: NavigationStart) => {
// Using NavigationStart instead of NavigationEnd so it can be check on ngOnInit.
this.previousPath = this.currentPath;
this.currentPath = routerEvent.url;
});
}
/**
* Check whether the active route is using the given path.
@ -267,17 +255,6 @@ export class CoreNavigatorService {
return CoreUrlUtils.removeUrlParams(Router.url);
}
/**
* Get the previous navigation route path.
*
* @return Previous path.
*/
getPreviousPath(): string {
// @todo: Remove this method and the used attributes.
// This is a quick workarround to avoid loops. Ie, in messages we can navigate to user profile and there to messages.
return CoreUrlUtils.removeUrlParams(this.previousPath || '');
}
/**
* Iterately get the params checking parent routes.
*