aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+search
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-17 16:02:38 +0200
committerChocobozzz <chocobozzz@cpy.re>2021-06-25 14:44:01 +0200
commit37a44fc915eef2140e22ceb96aba6b6eb2509007 (patch)
treedd4a370ecc96cf38c99b940261aadc27065da7ae /client/src/app/+search
parent33eb19e5199cc9fa4d73c6675c97508e3e072ef9 (diff)
downloadPeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.gz
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.tar.zst
PeerTube-37a44fc915eef2140e22ceb96aba6b6eb2509007.zip
Add ability to search playlists
Diffstat (limited to 'client/src/app/+search')
-rw-r--r--client/src/app/+search/channel-lazy-load.resolver.ts35
-rw-r--r--client/src/app/+search/search-routing.module.ts10
-rw-r--r--client/src/app/+search/search.component.html9
-rw-r--r--client/src/app/+search/search.component.ts146
-rw-r--r--client/src/app/+search/search.module.ts10
-rw-r--r--client/src/app/+search/shared/abstract-lazy-load.resolver.ts (renamed from client/src/app/+search/video-lazy-load.resolver.ts)21
-rw-r--r--client/src/app/+search/shared/channel-lazy-load.resolver.ts24
-rw-r--r--client/src/app/+search/shared/index.ts4
-rw-r--r--client/src/app/+search/shared/playlist-lazy-load.resolver.ts24
-rw-r--r--client/src/app/+search/shared/video-lazy-load.resolver.ts24
10 files changed, 193 insertions, 114 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 @@
1import { map } from 'rxjs/operators'
2import { Injectable } from '@angular/core'
3import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'
4import { SearchService } from '@app/shared/shared-search'
5
6@Injectable()
7export 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}
diff --git a/client/src/app/+search/search-routing.module.ts b/client/src/app/+search/search-routing.module.ts
index 0d778af0d..5d00aae13 100644
--- a/client/src/app/+search/search-routing.module.ts
+++ b/client/src/app/+search/search-routing.module.ts
@@ -1,8 +1,7 @@
1import { NgModule } from '@angular/core' 1import { NgModule } from '@angular/core'
2import { RouterModule, Routes } from '@angular/router' 2import { RouterModule, Routes } from '@angular/router'
3import { ChannelLazyLoadResolver } from './channel-lazy-load.resolver'
4import { SearchComponent } from './search.component' 3import { SearchComponent } from './search.component'
5import { VideoLazyLoadResolver } from './video-lazy-load.resolver' 4import { ChannelLazyLoadResolver, PlaylistLazyLoadResolver, VideoLazyLoadResolver } from './shared'
6 5
7const searchRoutes: Routes = [ 6const searchRoutes: Routes = [
8 { 7 {
@@ -27,6 +26,13 @@ const searchRoutes: Routes = [
27 resolve: { 26 resolve: {
28 data: ChannelLazyLoadResolver 27 data: ChannelLazyLoadResolver
29 } 28 }
29 },
30 {
31 path: 'lazy-load-playlist',
32 component: SearchComponent,
33 resolve: {
34 data: PlaylistLazyLoadResolver
35 }
30 } 36 }
31] 37]
32 38
diff --git a/client/src/app/+search/search.component.html b/client/src/app/+search/search.component.html
index 130be75fc..b28abca6a 100644
--- a/client/src/app/+search/search.component.html
+++ b/client/src/app/+search/search.component.html
@@ -59,10 +59,17 @@
59 <div *ngIf="isVideo(result)" class="entry video"> 59 <div *ngIf="isVideo(result)" class="entry video">
60 <my-video-miniature 60 <my-video-miniature
61 [video]="result" [user]="userMiniature" [displayAsRow]="true" [displayVideoActions]="!hideActions()" 61 [video]="result" [user]="userMiniature" [displayAsRow]="true" [displayVideoActions]="!hideActions()"
62 [displayOptions]="videoDisplayOptions" [videoLinkType]="getVideoLinkType()" 62 [displayOptions]="videoDisplayOptions" [videoLinkType]="getLinkType()"
63 (videoBlocked)="removeVideoFromArray(result)" (videoRemoved)="removeVideoFromArray(result)" 63 (videoBlocked)="removeVideoFromArray(result)" (videoRemoved)="removeVideoFromArray(result)"
64 ></my-video-miniature> 64 ></my-video-miniature>
65 </div> 65 </div>
66
67 <div *ngIf="isPlaylist(result)" class="entry video-playlist">
68 <my-video-playlist-miniature
69 [playlist]="result" [displayAsRow]="true" [displayChannel]="true"
70 [linkType]="getLinkType()"
71 ></my-video-playlist-miniature>
72 </div>
66 </ng-container> 73 </ng-container>
67 74
68</div> 75</div>
diff --git a/client/src/app/+search/search.component.ts b/client/src/app/+search/search.component.ts
index a4ab7a5b1..fdf9b7cc0 100644
--- a/client/src/app/+search/search.component.ts
+++ b/client/src/app/+search/search.component.ts
@@ -1,11 +1,13 @@
1import { forkJoin, of, Subscription } from 'rxjs' 1import { forkJoin, of, Subscription } from 'rxjs'
2import { LinkType } from 'src/types/link.type'
2import { Component, OnDestroy, OnInit } from '@angular/core' 3import { Component, OnDestroy, OnInit } from '@angular/core'
3import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
4import { AuthService, ComponentPagination, HooksService, MetaService, Notifier, ServerService, User, UserService } from '@app/core' 5import { AuthService, HooksService, MetaService, Notifier, ServerService, User, UserService } from '@app/core'
5import { immutableAssign } from '@app/helpers' 6import { immutableAssign } from '@app/helpers'
6import { Video, VideoChannel } from '@app/shared/shared-main' 7import { Video, VideoChannel } from '@app/shared/shared-main'
7import { AdvancedSearch, SearchService } from '@app/shared/shared-search' 8import { AdvancedSearch, SearchService } from '@app/shared/shared-search'
8import { MiniatureDisplayOptions, VideoLinkType } from '@app/shared/shared-video-miniature' 9import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
10import { VideoPlaylist } from '@app/shared/shared-video-playlist'
9import { HTMLServerConfig, SearchTargetType } from '@shared/models' 11import { HTMLServerConfig, SearchTargetType } from '@shared/models'
10 12
11@Component({ 13@Component({
@@ -16,10 +18,9 @@ import { HTMLServerConfig, SearchTargetType } from '@shared/models'
16export class SearchComponent implements OnInit, OnDestroy { 18export class SearchComponent implements OnInit, OnDestroy {
17 results: (Video | VideoChannel)[] = [] 19 results: (Video | VideoChannel)[] = []
18 20
19 pagination: ComponentPagination = { 21 pagination = {
20 currentPage: 1, 22 currentPage: 1,
21 itemsPerPage: 10, // Only for videos, use another variable for channels 23 totalItems: null as number
22 totalItems: null
23 } 24 }
24 advancedSearch: AdvancedSearch = new AdvancedSearch() 25 advancedSearch: AdvancedSearch = new AdvancedSearch()
25 isSearchFilterCollapsed = true 26 isSearchFilterCollapsed = true
@@ -45,6 +46,11 @@ export class SearchComponent implements OnInit, OnDestroy {
45 private firstSearch = true 46 private firstSearch = true
46 47
47 private channelsPerPage = 2 48 private channelsPerPage = 2
49 private playlistsPerPage = 2
50 private videosPerPage = 10
51
52 private hasMoreResults = true
53 private isSearching = false
48 54
49 private lastSearchTarget: SearchTargetType 55 private lastSearchTarget: SearchTargetType
50 56
@@ -104,77 +110,62 @@ export class SearchComponent implements OnInit, OnDestroy {
104 if (this.subActivatedRoute) this.subActivatedRoute.unsubscribe() 110 if (this.subActivatedRoute) this.subActivatedRoute.unsubscribe()
105 } 111 }
106 112
107 isVideoChannel (d: VideoChannel | Video): d is VideoChannel { 113 isVideoChannel (d: VideoChannel | Video | VideoPlaylist): d is VideoChannel {
108 return d instanceof VideoChannel 114 return d instanceof VideoChannel
109 } 115 }
110 116
111 isVideo (v: VideoChannel | Video): v is Video { 117 isVideo (v: VideoChannel | Video | VideoPlaylist): v is Video {
112 return v instanceof Video 118 return v instanceof Video
113 } 119 }
114 120
121 isPlaylist (v: VideoChannel | Video | VideoPlaylist): v is VideoPlaylist {
122 return v instanceof VideoPlaylist
123 }
124
115 isUserLoggedIn () { 125 isUserLoggedIn () {
116 return this.authService.isLoggedIn() 126 return this.authService.isLoggedIn()
117 } 127 }
118 128
119 getVideoLinkType (): VideoLinkType { 129 search () {
120 if (this.advancedSearch.searchTarget === 'search-index') { 130 this.isSearching = true
121 const remoteUriConfig = this.serverConfig.search.remoteUri
122 131
123 // Redirect on the external instance if not allowed to fetch remote data 132 forkJoin([
124 if ((!this.isUserLoggedIn() && !remoteUriConfig.anonymous) || !remoteUriConfig.users) { 133 this.getVideoChannelObs(),
125 return 'external' 134 this.getVideoPlaylistObs(),
135 this.getVideosObs()
136 ]).subscribe(results => {
137 for (const result of results) {
138 this.results = this.results.concat(result.data)
126 } 139 }
127 140
128 return 'lazy-load' 141 this.pagination.totalItems = results.reduce((p, r) => p += r.total, 0)
129 } 142 this.lastSearchTarget = this.advancedSearch.searchTarget
130 143
131 return 'internal' 144 this.hasMoreResults = this.results.length < this.pagination.totalItems
132 } 145 },
133 146
134 search () { 147 err => {
135 forkJoin([ 148 if (this.advancedSearch.searchTarget !== 'search-index') {
136 this.getVideosObs(), 149 this.notifier.error(err.message)
137 this.getVideoChannelObs() 150 return
138 ]).subscribe( 151 }
139 ([videosResult, videoChannelsResult]) => {
140 this.results = this.results
141 .concat(videoChannelsResult.data)
142 .concat(videosResult.data)
143
144 this.pagination.totalItems = videosResult.total + videoChannelsResult.total
145 this.lastSearchTarget = this.advancedSearch.searchTarget
146
147 // Focus on channels if there are no enough videos
148 if (this.firstSearch === true && videosResult.data.length < this.pagination.itemsPerPage) {
149 this.resetPagination()
150 this.firstSearch = false
151
152 this.channelsPerPage = 10
153 this.search()
154 }
155
156 this.firstSearch = false
157 },
158 152
159 err => { 153 this.notifier.error(
160 if (this.advancedSearch.searchTarget !== 'search-index') { 154 $localize`Search index is unavailable. Retrying with instance results instead.`,
161 this.notifier.error(err.message) 155 $localize`Search error`
162 return 156 )
163 } 157 this.advancedSearch.searchTarget = 'local'
158 this.search()
159 },
164 160
165 this.notifier.error( 161 () => {
166 $localize`Search index is unavailable. Retrying with instance results instead.`, 162 this.isSearching = false
167 $localize`Search error` 163 })
168 )
169 this.advancedSearch.searchTarget = 'local'
170 this.search()
171 }
172 )
173 } 164 }
174 165
175 onNearOfBottom () { 166 onNearOfBottom () {
176 // Last page 167 // Last page
177 if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return 168 if (!this.hasMoreResults || this.isSearching) return
178 169
179 this.pagination.currentPage += 1 170 this.pagination.currentPage += 1
180 this.search() 171 this.search()
@@ -190,18 +181,33 @@ export class SearchComponent implements OnInit, OnDestroy {
190 return this.advancedSearch.size() 181 return this.advancedSearch.size()
191 } 182 }
192 183
193 // Add VideoChannel for typings, but the template already checks "video" argument is a video 184 // Add VideoChannel/VideoPlaylist for typings, but the template already checks "video" argument is a video
194 removeVideoFromArray (video: Video | VideoChannel) { 185 removeVideoFromArray (video: Video | VideoChannel | VideoPlaylist) {
195 this.results = this.results.filter(r => !this.isVideo(r) || r.id !== video.id) 186 this.results = this.results.filter(r => !this.isVideo(r) || r.id !== video.id)
196 } 187 }
197 188
189 getLinkType (): LinkType {
190 if (this.advancedSearch.searchTarget === 'search-index') {
191 const remoteUriConfig = this.serverConfig.search.remoteUri
192
193 // Redirect on the external instance if not allowed to fetch remote data
194 if ((!this.isUserLoggedIn() && !remoteUriConfig.anonymous) || !remoteUriConfig.users) {
195 return 'external'
196 }
197
198 return 'lazy-load'
199 }
200
201 return 'internal'
202 }
203
198 isExternalChannelUrl () { 204 isExternalChannelUrl () {
199 return this.getVideoLinkType() === 'external' 205 return this.getLinkType() === 'external'
200 } 206 }
201 207
202 getExternalChannelUrl (channel: VideoChannel) { 208 getExternalChannelUrl (channel: VideoChannel) {
203 // Same algorithm than videos 209 // Same algorithm than videos
204 if (this.getVideoLinkType() === 'external') { 210 if (this.getLinkType() === 'external') {
205 return channel.url 211 return channel.url
206 } 212 }
207 213
@@ -210,7 +216,7 @@ export class SearchComponent implements OnInit, OnDestroy {
210 } 216 }
211 217
212 getInternalChannelUrl (channel: VideoChannel) { 218 getInternalChannelUrl (channel: VideoChannel) {
213 const linkType = this.getVideoLinkType() 219 const linkType = this.getLinkType()
214 220
215 if (linkType === 'internal') { 221 if (linkType === 'internal') {
216 return [ '/c', channel.nameWithHost ] 222 return [ '/c', channel.nameWithHost ]
@@ -256,7 +262,7 @@ export class SearchComponent implements OnInit, OnDestroy {
256 private getVideosObs () { 262 private getVideosObs () {
257 const params = { 263 const params = {
258 search: this.currentSearch, 264 search: this.currentSearch,
259 componentPagination: this.pagination, 265 componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.videosPerPage }),
260 advancedSearch: this.advancedSearch 266 advancedSearch: this.advancedSearch
261 } 267 }
262 268
@@ -287,6 +293,24 @@ export class SearchComponent implements OnInit, OnDestroy {
287 ) 293 )
288 } 294 }
289 295
296 private getVideoPlaylistObs () {
297 if (!this.currentSearch) return of({ data: [], total: 0 })
298
299 const params = {
300 search: this.currentSearch,
301 componentPagination: immutableAssign(this.pagination, { itemsPerPage: this.playlistsPerPage }),
302 searchTarget: this.advancedSearch.searchTarget
303 }
304
305 return this.hooks.wrapObsFun(
306 this.searchService.searchVideoPlaylists.bind(this.searchService),
307 params,
308 'search',
309 'filter:api.search.video-playlists.list.params',
310 'filter:api.search.video-playlists.list.result'
311 )
312 }
313
290 private getDefaultSearchTarget (): SearchTargetType { 314 private getDefaultSearchTarget (): SearchTargetType {
291 const searchIndexConfig = this.serverConfig.search.searchIndex 315 const searchIndexConfig = this.serverConfig.search.searchIndex
292 316
diff --git a/client/src/app/+search/search.module.ts b/client/src/app/+search/search.module.ts
index 390833abc..26f1523fd 100644
--- a/client/src/app/+search/search.module.ts
+++ b/client/src/app/+search/search.module.ts
@@ -5,12 +5,12 @@ import { SharedMainModule } from '@app/shared/shared-main'
5import { SharedSearchModule } from '@app/shared/shared-search' 5import { SharedSearchModule } from '@app/shared/shared-search'
6import { SharedUserSubscriptionModule } from '@app/shared/shared-user-subscription' 6import { SharedUserSubscriptionModule } from '@app/shared/shared-user-subscription'
7import { SharedVideoMiniatureModule } from '@app/shared/shared-video-miniature' 7import { SharedVideoMiniatureModule } from '@app/shared/shared-video-miniature'
8import { SharedVideoPlaylistModule } from '@app/shared/shared-video-playlist'
8import { SearchService } from '../shared/shared-search/search.service' 9import { SearchService } from '../shared/shared-search/search.service'
9import { ChannelLazyLoadResolver } from './channel-lazy-load.resolver'
10import { SearchFiltersComponent } from './search-filters.component' 10import { SearchFiltersComponent } from './search-filters.component'
11import { SearchRoutingModule } from './search-routing.module' 11import { SearchRoutingModule } from './search-routing.module'
12import { SearchComponent } from './search.component' 12import { SearchComponent } from './search.component'
13import { VideoLazyLoadResolver } from './video-lazy-load.resolver' 13import { ChannelLazyLoadResolver, PlaylistLazyLoadResolver, VideoLazyLoadResolver } from './shared'
14 14
15@NgModule({ 15@NgModule({
16 imports: [ 16 imports: [
@@ -21,7 +21,8 @@ import { VideoLazyLoadResolver } from './video-lazy-load.resolver'
21 SharedFormModule, 21 SharedFormModule,
22 SharedActorImageModule, 22 SharedActorImageModule,
23 SharedUserSubscriptionModule, 23 SharedUserSubscriptionModule,
24 SharedVideoMiniatureModule 24 SharedVideoMiniatureModule,
25 SharedVideoPlaylistModule
25 ], 26 ],
26 27
27 declarations: [ 28 declarations: [
@@ -36,7 +37,8 @@ import { VideoLazyLoadResolver } from './video-lazy-load.resolver'
36 providers: [ 37 providers: [
37 SearchService, 38 SearchService,
38 VideoLazyLoadResolver, 39 VideoLazyLoadResolver,
39 ChannelLazyLoadResolver 40 ChannelLazyLoadResolver,
41 PlaylistLazyLoadResolver
40 ] 42 ]
41}) 43})
42export class SearchModule { } 44export class SearchModule { }
diff --git a/client/src/app/+search/video-lazy-load.resolver.ts b/client/src/app/+search/shared/abstract-lazy-load.resolver.ts
index e43e0089b..31240f451 100644
--- a/client/src/app/+search/video-lazy-load.resolver.ts
+++ b/client/src/app/+search/shared/abstract-lazy-load.resolver.ts
@@ -1,14 +1,10 @@
1import { Observable } from 'rxjs'
1import { map } from 'rxjs/operators' 2import { map } from 'rxjs/operators'
2import { Injectable } from '@angular/core'
3import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router' 3import { ActivatedRouteSnapshot, Resolve, Router } from '@angular/router'
4import { SearchService } from '@app/shared/shared-search' 4import { ResultList } from '@shared/models/result-list.model'
5 5
6@Injectable() 6export abstract class AbstractLazyLoadResolver <T> implements Resolve<any> {
7export class VideoLazyLoadResolver implements Resolve<any> { 7 protected router: Router
8 constructor (
9 private router: Router,
10 private searchService: SearchService
11 ) { }
12 8
13 resolve (route: ActivatedRouteSnapshot) { 9 resolve (route: ActivatedRouteSnapshot) {
14 const url = route.params.url 10 const url = route.params.url
@@ -18,7 +14,7 @@ export class VideoLazyLoadResolver implements Resolve<any> {
18 return this.router.navigateByUrl('/404') 14 return this.router.navigateByUrl('/404')
19 } 15 }
20 16
21 return this.searchService.searchVideos({ search: url }) 17 return this.finder(url)
22 .pipe( 18 .pipe(
23 map(result => { 19 map(result => {
24 if (result.data.length !== 1) { 20 if (result.data.length !== 1) {
@@ -26,10 +22,13 @@ export class VideoLazyLoadResolver implements Resolve<any> {
26 return this.router.navigateByUrl('/404') 22 return this.router.navigateByUrl('/404')
27 } 23 }
28 24
29 const video = result.data[0] 25 const redirectUrl = this.buildUrl(result.data[0])
30 26
31 return this.router.navigateByUrl('/w/' + video.uuid) 27 return this.router.navigateByUrl(redirectUrl)
32 }) 28 })
33 ) 29 )
34 } 30 }
31
32 protected abstract finder (url: string): Observable<ResultList<T>>
33 protected abstract buildUrl (e: T): string
35} 34}
diff --git a/client/src/app/+search/shared/channel-lazy-load.resolver.ts b/client/src/app/+search/shared/channel-lazy-load.resolver.ts
new file mode 100644
index 000000000..5e010f795
--- /dev/null
+++ b/client/src/app/+search/shared/channel-lazy-load.resolver.ts
@@ -0,0 +1,24 @@
1import { Injectable } from '@angular/core'
2import { Router } from '@angular/router'
3import { VideoChannel } from '@app/shared/shared-main'
4import { SearchService } from '@app/shared/shared-search'
5import { AbstractLazyLoadResolver } from './abstract-lazy-load.resolver'
6
7@Injectable()
8export class ChannelLazyLoadResolver extends AbstractLazyLoadResolver<VideoChannel> {
9
10 constructor (
11 protected router: Router,
12 private searchService: SearchService
13 ) {
14 super()
15 }
16
17 protected finder (url: string) {
18 return this.searchService.searchVideoChannels({ search: url })
19 }
20
21 protected buildUrl (channel: VideoChannel) {
22 return '/video-channels/' + channel.nameWithHost
23 }
24}
diff --git a/client/src/app/+search/shared/index.ts b/client/src/app/+search/shared/index.ts
new file mode 100644
index 000000000..1e68989ae
--- /dev/null
+++ b/client/src/app/+search/shared/index.ts
@@ -0,0 +1,4 @@
1export * from './abstract-lazy-load.resolver'
2export * from './channel-lazy-load.resolver'
3export * from './playlist-lazy-load.resolver'
4export * from './video-lazy-load.resolver'
diff --git a/client/src/app/+search/shared/playlist-lazy-load.resolver.ts b/client/src/app/+search/shared/playlist-lazy-load.resolver.ts
new file mode 100644
index 000000000..14ae798df
--- /dev/null
+++ b/client/src/app/+search/shared/playlist-lazy-load.resolver.ts
@@ -0,0 +1,24 @@
1import { Injectable } from '@angular/core'
2import { Router } from '@angular/router'
3import { SearchService } from '@app/shared/shared-search'
4import { VideoPlaylist } from '@app/shared/shared-video-playlist'
5import { AbstractLazyLoadResolver } from './abstract-lazy-load.resolver'
6
7@Injectable()
8export class PlaylistLazyLoadResolver extends AbstractLazyLoadResolver<VideoPlaylist> {
9
10 constructor (
11 protected router: Router,
12 private searchService: SearchService
13 ) {
14 super()
15 }
16
17 protected finder (url: string) {
18 return this.searchService.searchVideoPlaylists({ search: url })
19 }
20
21 protected buildUrl (playlist: VideoPlaylist) {
22 return '/w/p/' + playlist.uuid
23 }
24}
diff --git a/client/src/app/+search/shared/video-lazy-load.resolver.ts b/client/src/app/+search/shared/video-lazy-load.resolver.ts
new file mode 100644
index 000000000..12b5b2e82
--- /dev/null
+++ b/client/src/app/+search/shared/video-lazy-load.resolver.ts
@@ -0,0 +1,24 @@
1import { Injectable } from '@angular/core'
2import { Router } from '@angular/router'
3import { Video } from '@app/shared/shared-main'
4import { SearchService } from '@app/shared/shared-search'
5import { AbstractLazyLoadResolver } from './abstract-lazy-load.resolver'
6
7@Injectable()
8export class VideoLazyLoadResolver extends AbstractLazyLoadResolver<Video> {
9
10 constructor (
11 protected router: Router,
12 private searchService: SearchService
13 ) {
14 super()
15 }
16
17 protected finder (url: string) {
18 return this.searchService.searchVideos({ search: url })
19 }
20
21 protected buildUrl (video: Video) {
22 return '/w/' + video.uuid
23 }
24}