MOBILE-3320 navigation: Remove path tracking
parent
b396bfdf6f
commit
e2987a44b7
|
@ -158,15 +158,13 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
|
||||||
* Setup code for the page.
|
* Setup code for the page.
|
||||||
*/
|
*/
|
||||||
async ngOnInit(): Promise<void> {
|
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) => {
|
this.route.queryParams.subscribe(async (params) => {
|
||||||
const oldConversationId = this.conversationId;
|
const oldConversationId = this.conversationId;
|
||||||
const oldUserId = this.userId;
|
const oldUserId = this.userId;
|
||||||
this.conversationId = CoreNavigator.getRouteNumberParam('conversationId', { params }) || undefined;
|
this.conversationId = CoreNavigator.getRouteNumberParam('conversationId', { params }) || undefined;
|
||||||
this.userId = CoreNavigator.getRouteNumberParam('userId', { params }) || undefined;
|
this.userId = CoreNavigator.getRouteNumberParam('userId', { params }) || undefined;
|
||||||
|
this.showInfo = !params.hideInfo;
|
||||||
|
|
||||||
if (oldConversationId != this.conversationId || oldUserId != this.userId) {
|
if (oldConversationId != this.conversationId || oldUserId != this.userId) {
|
||||||
// Showing reload again can break animations.
|
// Showing reload again can break animations.
|
||||||
|
|
|
@ -77,6 +77,7 @@ export class AddonMessagesSendMessageUserHandlerService implements CoreUserProfi
|
||||||
const pageParams: Params = {
|
const pageParams: Params = {
|
||||||
showKeyboard: true,
|
showKeyboard: true,
|
||||||
userId: user.id,
|
userId: user.id,
|
||||||
|
hideInfo: true,
|
||||||
};
|
};
|
||||||
CoreNavigator.navigateToSitePath('/messages/discussion', { params: pageParams });
|
CoreNavigator.navigateToSitePath('/messages/discussion', { params: pageParams });
|
||||||
},
|
},
|
||||||
|
|
|
@ -361,6 +361,7 @@ export class AddonModFeedbackIndexComponent extends CoreCourseModuleMainActivity
|
||||||
{
|
{
|
||||||
params: {
|
params: {
|
||||||
preview,
|
preview,
|
||||||
|
fromIndex: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -61,6 +61,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
|
|
||||||
title?: string;
|
title?: string;
|
||||||
preview = false;
|
preview = false;
|
||||||
|
fromIndex = false;
|
||||||
cmId!: number;
|
cmId!: number;
|
||||||
courseId!: number;
|
courseId!: number;
|
||||||
feedback?: AddonModFeedbackWSFeedback;
|
feedback?: AddonModFeedbackWSFeedback;
|
||||||
|
@ -96,6 +97,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
this.currentPage = CoreNavigator.getRouteNumberParam('page');
|
this.currentPage = CoreNavigator.getRouteNumberParam('page');
|
||||||
this.title = CoreNavigator.getRouteParam('title');
|
this.title = CoreNavigator.getRouteParam('title');
|
||||||
this.preview = !!CoreNavigator.getRouteBooleanParam('preview');
|
this.preview = !!CoreNavigator.getRouteBooleanParam('preview');
|
||||||
|
this.fromIndex = !!CoreNavigator.getRouteBooleanParam('fromIndex');
|
||||||
|
|
||||||
await this.fetchData();
|
await this.fetchData();
|
||||||
|
|
||||||
|
@ -373,10 +375,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
* Function to link implemented features.
|
* Function to link implemented features.
|
||||||
*/
|
*/
|
||||||
showAnalysis(): void {
|
showAnalysis(): void {
|
||||||
const indexPath = AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`;
|
if (this.fromIndex) {
|
||||||
const previousPath = CoreNavigator.getPreviousPath();
|
|
||||||
|
|
||||||
if (previousPath.match(new RegExp(indexPath + '$'))) {
|
|
||||||
// Previous page is the index page, go back.
|
// Previous page is the index page, go back.
|
||||||
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
|
CoreEvents.trigger(AddonModFeedbackProvider.FORM_SUBMITTED, {
|
||||||
feedbackId: this.feedback!.id,
|
feedbackId: this.feedback!.id,
|
||||||
|
@ -389,7 +388,7 @@ export class AddonModFeedbackFormPage implements OnInit, OnDestroy, CanLeave {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreNavigator.navigateToSitePath(indexPath, {
|
CoreNavigator.navigateToSitePath(AddonModFeedbackModuleHandlerService.PAGE_NAME + `/${this.courseId}/${this.cmId}`, {
|
||||||
params: {
|
params: {
|
||||||
module: this.module,
|
module: this.module,
|
||||||
tab: 'analysis',
|
tab: 'analysis',
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import { Injectable } from '@angular/core';
|
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';
|
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 { CoreTextUtils } from '@services/utils/text';
|
||||||
import { makeSingleton, NavController, Router } from '@singletons';
|
import { makeSingleton, NavController, Router } from '@singletons';
|
||||||
import { CoreScreen } from './screen';
|
import { CoreScreen } from './screen';
|
||||||
import { filter } from 'rxjs/operators';
|
|
||||||
import { CoreApp } from './app';
|
import { CoreApp } from './app';
|
||||||
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
import { CoreSitePlugins } from '@features/siteplugins/services/siteplugins';
|
||||||
|
|
||||||
|
@ -75,17 +74,6 @@ export class CoreNavigatorService {
|
||||||
|
|
||||||
protected storedParams: Record<number, unknown> = {};
|
protected storedParams: Record<number, unknown> = {};
|
||||||
protected lastParamId = 0;
|
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.
|
* Check whether the active route is using the given path.
|
||||||
|
@ -267,17 +255,6 @@ export class CoreNavigatorService {
|
||||||
return CoreUrlUtils.removeUrlParams(Router.url);
|
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.
|
* Iterately get the params checking parent routes.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue