MOBILE-3708 core: Always remove empty params in navigator

main
Dani Palou 2021-02-25 14:44:06 +01:00
parent 65d097b498
commit 200b01eef6
8 changed files with 14 additions and 22 deletions

View File

@ -22,7 +22,6 @@ import { CoreUtils } from '@services/utils/utils';
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
import { ActivatedRoute, ActivatedRouteSnapshot, Params } from '@angular/router';
import { CoreSplitViewComponent } from '@components/split-view/split-view';
import { CoreObject } from '@singletons/object';
/**
* Page that displays the list of calendar events.
@ -125,10 +124,10 @@ class AddonBadgesUserBadgesManager extends CorePageItemsListManager<AddonBadgesU
* @inheritdoc
*/
protected getItemQueryParams(): Params {
return CoreObject.withoutEmpty({
return {
courseId: this.courseId,
userId: this.userId,
});
};
}
/**

View File

@ -18,7 +18,6 @@ import { CoreUserProfile } from '@features/user/services/user';
import { CoreUserDelegateService, CoreUserProfileHandler, CoreUserProfileHandlerData } from '@features/user/services/user-delegate';
import { CoreNavigator } from '@services/navigator';
import { makeSingleton } from '@singletons';
import { CoreObject } from '@singletons/object';
import { AddonBadges } from '../badges';
/**
@ -74,7 +73,7 @@ export class AddonBadgesUserHandlerService implements CoreUserProfileHandler {
event.preventDefault();
event.stopPropagation();
CoreNavigator.navigateToSitePath('/badges', {
params: CoreObject.withoutEmpty({ courseId, userId: user.id }),
params: { courseId, userId: user.id },
});
},
};

View File

@ -24,7 +24,6 @@ import { CoreDomUtils } from '@services/utils/dom';
import { CoreUtils } from '@services/utils/utils';
import { Translate } from '@singletons';
import { CoreEventObserver, CoreEvents } from '@singletons/events';
import { CoreObject } from '@singletons/object';
import {
AddonModAssignAssign,
AddonModAssignSubmission,
@ -368,9 +367,9 @@ class AddonModAssignSubmissionListManager extends CorePageItemsListManager<Addon
* @inheritdoc
*/
protected getItemQueryParams(submission: AddonModAssignSubmissionForList): Params {
return CoreObject.withoutEmpty({
return {
blindId: submission.blindid,
});
};
}
/**

View File

@ -15,8 +15,6 @@
import { Directive, Input, OnInit, ElementRef } from '@angular/core';
import { CoreNavigator } from '@services/navigator';
import { CoreObject } from '@singletons/object';
/**
* Directive to go to user profile on click.
*/
@ -50,10 +48,10 @@ export class CoreUserLinkDirective implements OnInit {
event.stopPropagation();
CoreNavigator.navigateToSitePath('user', {
params: CoreObject.withoutEmpty({
params: {
userId: this.userId,
courseId: this.courseId,
}),
},
});
});
}

View File

@ -27,7 +27,6 @@ import {
import { CoreSites } from '@services/sites';
import { CoreUtils } from '@services/utils/utils';
import { CoreSplitViewComponent, CoreSplitViewMode } from '@components/split-view/split-view';
import { CoreObject } from '@singletons/object';
import { CorePageItemsListManager } from '@classes/page-items-list-manager';
import { CoreNavigator } from '@services/navigator';
@ -174,7 +173,7 @@ class CoreGradesCourseManager extends CorePageItemsListManager<CoreGradesFormatt
* @inheritdoc
*/
protected getItemQueryParams(): Params {
return CoreObject.withoutEmpty({ userId: this.userId });
return { userId: this.userId };
}
/**

View File

@ -33,7 +33,6 @@ import { makeSingleton, Translate } from '@singletons';
import { CoreLogger } from '@singletons/logger';
import { CoreUrl } from '@singletons/url';
import { CoreNavigator } from '@services/navigator';
import { CoreObject } from '@singletons/object';
/**
* Helper provider that provides some common features regarding authentication.
@ -428,7 +427,7 @@ export class CoreLoginHelperProvider {
return ['/login/credentials', { siteUrl: url }];
}
return ['/login/site', CoreObject.withoutEmpty({ showKeyboard: showKeyboard })];
return ['/login/site', { showKeyboard }];
}
/**

View File

@ -17,7 +17,6 @@ import { CanActivate, CanLoad, UrlTree } from '@angular/router';
import { CoreApp } from '@services/app';
import { CoreSites } from '@services/sites';
import { Router } from '@singletons';
import { CoreObject } from '@singletons/object';
import { CoreConstants } from '../constants';
@Injectable({ providedIn: 'root' })
@ -62,10 +61,10 @@ export class CoreRedirectGuard implements CanLoad, CanActivate {
);
const route = Router.parseUrl('/main');
route.queryParams = CoreObject.withoutEmpty({
route.queryParams = {
redirectPath: redirect.page,
redirectParams: redirect.params,
});
};
return loggedIn ? route : true;
}
@ -78,10 +77,10 @@ export class CoreRedirectGuard implements CanLoad, CanActivate {
// Redirect to non-site path.
const route = Router.parseUrl(redirect.page);
route.queryParams = CoreObject.withoutEmpty({
route.queryParams = {
redirectPath: redirect.page,
redirectParams: redirect.params,
});
};
return route;
} finally {

View File

@ -127,7 +127,7 @@ export class CoreNavigatorService {
const url: string[] = [/^[./]/.test(path) ? path : `./${path}`];
const navigationOptions: NavigationOptions = CoreObject.withoutEmpty({
animated: options.animated,
queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : options.params,
queryParams: CoreObject.isEmpty(options.params ?? {}) ? null : CoreObject.withoutEmpty(options.params),
relativeTo: path.startsWith('/') ? null : this.getCurrentRoute(),
});