aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/routing
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-04 14:39:47 +0200
committerChocobozzz <me@florianbigard.com>2021-06-04 15:45:44 +0200
commitfc21ef5c62d845576a916414468b3a57370a57b2 (patch)
tree818102bc909210870f9a28692361f7b5cbe219de /client/src/app/core/routing
parent2989628b7913383b39ac34c7db8666a21f8e5037 (diff)
downloadPeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.tar.gz
PeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.tar.zst
PeerTube-fc21ef5c62d845576a916414468b3a57370a57b2.zip
Speed up plugins loading
Diffstat (limited to 'client/src/app/core/routing')
-rw-r--r--client/src/app/core/routing/homepage-redirect.component.ts30
-rw-r--r--client/src/app/core/routing/index.ts1
-rw-r--r--client/src/app/core/routing/redirect.service.ts1
3 files changed, 31 insertions, 1 deletions
diff --git a/client/src/app/core/routing/homepage-redirect.component.ts b/client/src/app/core/routing/homepage-redirect.component.ts
new file mode 100644
index 000000000..9e3848038
--- /dev/null
+++ b/client/src/app/core/routing/homepage-redirect.component.ts
@@ -0,0 +1,30 @@
1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute } from '@angular/router'
3import { is18nPath } from '@shared/core-utils/i18n/i18n'
4import { RedirectService } from './redirect.service'
5
6/*
7 * We have to use a component instead of an homepage because of a weird issue when using router.navigate in guard
8 *
9 * Since we also want to use the `skipLocationChange` option, we cannot use a guard that returns a UrlTree
10 * See https://github.com/angular/angular/issues/27148
11*/
12
13@Component({
14 template: ''
15})
16export class HomepageRedirectComponent implements OnInit {
17
18 constructor (
19 private route: ActivatedRoute,
20 private redirectService: RedirectService
21 ) { }
22
23 ngOnInit () {
24 const url = this.route.snapshot.url
25
26 if (url.length === 0 || is18nPath('/' + url[0])) {
27 this.redirectService.redirectToHomepage(true)
28 }
29 }
30}
diff --git a/client/src/app/core/routing/index.ts b/client/src/app/core/routing/index.ts
index 4314ea475..d0c688a2f 100644
--- a/client/src/app/core/routing/index.ts
+++ b/client/src/app/core/routing/index.ts
@@ -1,6 +1,7 @@
1export * from './can-deactivate-guard.service' 1export * from './can-deactivate-guard.service'
2export * from './custom-reuse-strategy' 2export * from './custom-reuse-strategy'
3export * from './disable-for-reuse-hook' 3export * from './disable-for-reuse-hook'
4export * from './homepage-redirect.component'
4export * from './login-guard.service' 5export * from './login-guard.service'
5export * from './menu-guard.service' 6export * from './menu-guard.service'
6export * from './meta-guard.service' 7export * from './meta-guard.service'
diff --git a/client/src/app/core/routing/redirect.service.ts b/client/src/app/core/routing/redirect.service.ts
index 198332b00..17d9d1358 100644
--- a/client/src/app/core/routing/redirect.service.ts
+++ b/client/src/app/core/routing/redirect.service.ts
@@ -42,7 +42,6 @@ export class RedirectService {
42 return this.defaultRoute 42 return this.defaultRoute
43 } 43 }
44 44
45
46 getDefaultTrendingAlgorithm () { 45 getDefaultTrendingAlgorithm () {
47 return this.defaultTrendingAlgorithm 46 return this.defaultTrendingAlgorithm
48 } 47 }