]>
Commit | Line | Data |
---|---|---|
1 | import { NgModule } from '@angular/core' | |
2 | import { RouterModule, Routes, UrlSegment } from '@angular/router' | |
3 | import { LoginGuard } from '@app/core' | |
4 | import { VideosListCommonPageComponent } from './video-list' | |
5 | import { VideoOverviewComponent } from './video-list/overview/video-overview.component' | |
6 | import { VideoUserSubscriptionsComponent } from './video-list/video-user-subscriptions.component' | |
7 | ||
8 | const videosRoutes: Routes = [ | |
9 | { | |
10 | path: '', | |
11 | children: [ | |
12 | { | |
13 | path: 'overview', | |
14 | component: VideoOverviewComponent, | |
15 | data: { | |
16 | meta: { | |
17 | title: $localize`Discover videos` | |
18 | } | |
19 | } | |
20 | }, | |
21 | ||
22 | { | |
23 | // Old URL redirection | |
24 | path: 'most-liked', | |
25 | redirectTo: 'trending?sort=most-liked' | |
26 | }, | |
27 | { | |
28 | matcher: (url: UrlSegment[]) => { | |
29 | if (url.length === 1 && [ 'recently-added', 'trending', 'local' ].includes(url[0].path)) { | |
30 | return { | |
31 | consumed: url, | |
32 | posParams: { | |
33 | page: new UrlSegment(url[0].path, {}) | |
34 | } | |
35 | } | |
36 | } | |
37 | ||
38 | return null | |
39 | }, | |
40 | ||
41 | component: VideosListCommonPageComponent, | |
42 | data: { | |
43 | reuse: { | |
44 | enabled: true, | |
45 | key: 'videos-list' | |
46 | } | |
47 | } | |
48 | }, | |
49 | ||
50 | { | |
51 | path: 'subscriptions', | |
52 | canActivate: [ LoginGuard ], | |
53 | component: VideoUserSubscriptionsComponent, | |
54 | data: { | |
55 | meta: { | |
56 | title: $localize`Subscriptions` | |
57 | }, | |
58 | reuse: { | |
59 | enabled: true, | |
60 | key: 'subscription-videos-list' | |
61 | } | |
62 | } | |
63 | } | |
64 | ] | |
65 | } | |
66 | ] | |
67 | ||
68 | @NgModule({ | |
69 | imports: [ RouterModule.forChild(videosRoutes) ], | |
70 | exports: [ RouterModule ] | |
71 | }) | |
72 | export class VideosRoutingModule {} |