1 import { NgModule } from '@angular/core'
2 import { RouteReuseStrategy, RouterModule, Routes, UrlMatchResult, UrlSegment } from '@angular/router'
3 import { CustomReuseStrategy } from '@app/core/routing/custom-reuse-strategy'
4 import { MenuGuards } from '@app/core/routing/menu-guard.service'
5 import { POSSIBLE_LOCALES } from '@shared/core-utils/i18n'
6 import { PreloadSelectedModulesList } from './core'
7 import { EmptyComponent } from './empty.component'
8 import { RootComponent } from './root.component'
10 const routes: Routes = [
13 canActivate: [ MenuGuards.close() ],
14 canDeactivate: [ MenuGuards.open() ],
15 loadChildren: () => import('./+admin/admin.module').then(m => m.AdminModule)
19 loadChildren: () => import('./+my-account/my-account.module').then(m => m.MyAccountModule)
23 loadChildren: () => import('./+my-library/my-library.module').then(m => m.MyLibraryModule)
26 path: 'verify-account',
27 loadChildren: () => import('./+signup/+verify-account/verify-account.module').then(m => m.VerifyAccountModule)
31 loadChildren: () => import('./+accounts/accounts.module').then(m => m.AccountsModule)
35 loadChildren: () => import('./+video-channels/video-channels.module').then(m => m.VideoChannelsModule)
39 loadChildren: () => import('./+about/about.module').then(m => m.AboutModule)
43 loadChildren: () => import('./+signup/+register/register.module').then(m => m.RegisterModule)
46 path: 'reset-password',
47 loadChildren: () => import('./+reset-password/reset-password.module').then(m => m.ResetPasswordModule)
51 loadChildren: () => import('./+login/login.module').then(m => m.LoginModule)
55 loadChildren: () => import('./+search/search.module').then(m => m.SearchModule)
59 loadChildren: () => import('./+videos/videos.module').then(m => m.VideosModule)
62 path: 'remote-interaction',
63 loadChildren: () => import('./+remote-interaction/remote-interaction.module').then(m => m.RemoteInteractionModule)
66 path: 'video-playlists/watch',
67 redirectTo: 'videos/watch/playlist'
74 path: 'video-channels',
78 matcher: (url): UrlMatchResult => {
79 // Matches /@:actorName
80 if (url.length === 1 && url[0].path.match(/^@[\w]+$/gm)) {
84 actorName: new UrlSegment(url[0].path.substr(1), {})
91 component: RootComponent
95 component: EmptyComponent // Avoid 404, app component will redirect dynamically
99 // Avoid 404 when changing language
100 for (const locale of POSSIBLE_LOCALES) {
103 component: EmptyComponent
109 loadChildren: () => import('./+page-not-found/page-not-found.module').then(m => m.PageNotFoundModule)
114 RouterModule.forRoot(routes, {
115 useHash: Boolean(history.pushState) === false,
116 scrollPositionRestoration: 'disabled',
117 preloadingStrategy: PreloadSelectedModulesList,
118 anchorScrolling: 'disabled'
123 PreloadSelectedModulesList,
124 { provide: RouteReuseStrategy, useClass: CustomReuseStrategy }
126 exports: [ RouterModule ]
128 export class AppRoutingModule {}