diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-17 16:02:38 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-06-25 14:44:01 +0200 |
commit | 37a44fc915eef2140e22ceb96aba6b6eb2509007 (patch) | |
tree | dd4a370ecc96cf38c99b940261aadc27065da7ae /client/src/app/+search/channel-lazy-load.resolver.ts | |
parent | 33eb19e5199cc9fa4d73c6675c97508e3e072ef9 (diff) | |
download | PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.gz PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.zst PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.zip |
Add ability to search playlists
Diffstat (limited to 'client/src/app/+search/channel-lazy-load.resolver.ts')
-rw-r--r-- | client/src/app/+search/channel-lazy-load.resolver.ts | 35 |
1 files changed, 0 insertions, 35 deletions
diff --git a/client/src/app/+search/channel-lazy-load.resolver.ts b/client/src/app/+search/channel-lazy-load.resolver.ts deleted file mode 100644 index d9f7ec901..000000000 --- a/client/src/app/+search/channel-lazy-load.resolver.ts +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | import { map } from 'rxjs/operators' | ||
2 | import { Injectable } from '@angular/core' | ||
3 | import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router' | ||
4 | import { SearchService } from '@app/shared/shared-search' | ||
5 | |||
6 | @Injectable() | ||
7 | export class ChannelLazyLoadResolver implements Resolve<any> { | ||
8 | constructor ( | ||
9 | private router: Router, | ||
10 | private searchService: SearchService | ||
11 | ) { } | ||
12 | |||
13 | resolve (route: ActivatedRouteSnapshot) { | ||
14 | const url = route.params.url | ||
15 | |||
16 | if (!url) { | ||
17 | console.error('Could not find url param.', { params: route.params }) | ||
18 | return this.router.navigateByUrl('/404') | ||
19 | } | ||
20 | |||
21 | return this.searchService.searchVideoChannels({ search: url }) | ||
22 | .pipe( | ||
23 | map(result => { | ||
24 | if (result.data.length !== 1) { | ||
25 | console.error('Cannot find result for this URL') | ||
26 | return this.router.navigateByUrl('/404') | ||
27 | } | ||
28 | |||
29 | const channel = result.data[0] | ||
30 | |||
31 | return this.router.navigateByUrl('/video-channels/' + channel.nameWithHost) | ||
32 | }) | ||
33 | ) | ||
34 | } | ||
35 | } | ||