diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-23 14:49:20 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-06-23 16:00:49 +0200 |
commit | 1942f11d5ee6926ad93dc1b79fae18325ba5de18 (patch) | |
tree | 3f2a3cd9466a56c419d197ac832a3e9cbc86bec4 /client/src/app/videos/recommendations/recommended-videos.store.ts | |
parent | 67ed6552b831df66713bac9e672738796128d33f (diff) | |
download | PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.gz PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.tar.zst PeerTube-1942f11d5ee6926ad93dc1b79fae18325ba5de18.zip |
Lazy load all routes
Diffstat (limited to 'client/src/app/videos/recommendations/recommended-videos.store.ts')
-rw-r--r-- | client/src/app/videos/recommendations/recommended-videos.store.ts | 37 |
1 files changed, 0 insertions, 37 deletions
diff --git a/client/src/app/videos/recommendations/recommended-videos.store.ts b/client/src/app/videos/recommendations/recommended-videos.store.ts deleted file mode 100644 index 8c3fb6480..000000000 --- a/client/src/app/videos/recommendations/recommended-videos.store.ts +++ /dev/null | |||
@@ -1,37 +0,0 @@ | |||
1 | import { Observable, ReplaySubject } from 'rxjs' | ||
2 | import { map, shareReplay, switchMap, take } from 'rxjs/operators' | ||
3 | import { Inject, Injectable } from '@angular/core' | ||
4 | import { Video } from '@app/shared/shared-main' | ||
5 | import { RecentVideosRecommendationService } from './recent-videos-recommendation.service' | ||
6 | import { RecommendationInfo } from './recommendation-info.model' | ||
7 | import { RecommendationService } from './recommendations.service' | ||
8 | |||
9 | /** | ||
10 | * This store is intended to provide data for the RecommendedVideosComponent. | ||
11 | */ | ||
12 | @Injectable() | ||
13 | export class RecommendedVideosStore { | ||
14 | public readonly recommendations$: Observable<Video[]> | ||
15 | public readonly hasRecommendations$: Observable<boolean> | ||
16 | private readonly requestsForLoad$$ = new ReplaySubject<RecommendationInfo>(1) | ||
17 | |||
18 | constructor ( | ||
19 | @Inject(RecentVideosRecommendationService) private recommendations: RecommendationService | ||
20 | ) { | ||
21 | this.recommendations$ = this.requestsForLoad$$.pipe( | ||
22 | switchMap(requestedRecommendation => { | ||
23 | return this.recommendations.getRecommendations(requestedRecommendation) | ||
24 | .pipe(take(1)) | ||
25 | }), | ||
26 | shareReplay() | ||
27 | ) | ||
28 | |||
29 | this.hasRecommendations$ = this.recommendations$.pipe( | ||
30 | map(otherVideos => otherVideos.length > 0) | ||
31 | ) | ||
32 | } | ||
33 | |||
34 | requestNewRecommendations (recommend: RecommendationInfo) { | ||
35 | this.requestsForLoad$$.next(recommend) | ||
36 | } | ||
37 | } | ||