diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/user-subscription/user-subscription.service.ts | 18 | ||||
-rw-r--r-- | client/src/app/shared/video/infinite-scroller.directive.ts | 4 |
2 files changed, 13 insertions, 9 deletions
diff --git a/client/src/app/shared/user-subscription/user-subscription.service.ts b/client/src/app/shared/user-subscription/user-subscription.service.ts index cf622019f..3d05f071e 100644 --- a/client/src/app/shared/user-subscription/user-subscription.service.ts +++ b/client/src/app/shared/user-subscription/user-subscription.service.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { bufferTime, catchError, filter, map, share, switchMap, tap } from 'rxjs/operators' | 1 | import { bufferTime, catchError, filter, first, map, share, switchMap } from 'rxjs/operators' |
2 | import { HttpClient, HttpParams } from '@angular/common/http' | 2 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { ResultList } from '../../../../../shared' | 4 | import { ResultList } from '../../../../../shared' |
@@ -8,6 +8,7 @@ import { Observable, ReplaySubject, Subject } from 'rxjs' | |||
8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | 8 | import { VideoChannel } from '@app/shared/video-channel/video-channel.model' |
9 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' | 9 | import { VideoChannelService } from '@app/shared/video-channel/video-channel.service' |
10 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' | 10 | import { VideoChannel as VideoChannelServer } from '../../../../../shared/models/videos' |
11 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | ||
11 | 12 | ||
12 | type SubscriptionExistResult = { [ uri: string ]: boolean } | 13 | type SubscriptionExistResult = { [ uri: string ]: boolean } |
13 | 14 | ||
@@ -17,7 +18,7 @@ export class UserSubscriptionService { | |||
17 | 18 | ||
18 | // Use a replay subject because we "next" a value before subscribing | 19 | // Use a replay subject because we "next" a value before subscribing |
19 | private existsSubject: Subject<string> = new ReplaySubject(1) | 20 | private existsSubject: Subject<string> = new ReplaySubject(1) |
20 | private existsObservable: Observable<SubscriptionExistResult> | 21 | private readonly existsObservable: Observable<SubscriptionExistResult> |
21 | 22 | ||
22 | constructor ( | 23 | constructor ( |
23 | private authHttp: HttpClient, | 24 | private authHttp: HttpClient, |
@@ -25,7 +26,6 @@ export class UserSubscriptionService { | |||
25 | private restService: RestService | 26 | private restService: RestService |
26 | ) { | 27 | ) { |
27 | this.existsObservable = this.existsSubject.pipe( | 28 | this.existsObservable = this.existsSubject.pipe( |
28 | tap(u => console.log(u)), | ||
29 | bufferTime(500), | 29 | bufferTime(500), |
30 | filter(uris => uris.length !== 0), | 30 | filter(uris => uris.length !== 0), |
31 | switchMap(uris => this.areSubscriptionExist(uris)), | 31 | switchMap(uris => this.areSubscriptionExist(uris)), |
@@ -54,10 +54,15 @@ export class UserSubscriptionService { | |||
54 | ) | 54 | ) |
55 | } | 55 | } |
56 | 56 | ||
57 | listSubscriptions (): Observable<ResultList<VideoChannel>> { | 57 | listSubscriptions (componentPagination: ComponentPagination): Observable<ResultList<VideoChannel>> { |
58 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL | 58 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL |
59 | 59 | ||
60 | return this.authHttp.get<ResultList<VideoChannelServer>>(url) | 60 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) |
61 | |||
62 | let params = new HttpParams() | ||
63 | params = this.restService.addRestGetParams(params, pagination) | ||
64 | |||
65 | return this.authHttp.get<ResultList<VideoChannelServer>>(url, { params }) | ||
61 | .pipe( | 66 | .pipe( |
62 | map(res => VideoChannelService.extractVideoChannels(res)), | 67 | map(res => VideoChannelService.extractVideoChannels(res)), |
63 | catchError(err => this.restExtractor.handleError(err)) | 68 | catchError(err => this.restExtractor.handleError(err)) |
@@ -67,11 +72,10 @@ export class UserSubscriptionService { | |||
67 | isSubscriptionExists (nameWithHost: string) { | 72 | isSubscriptionExists (nameWithHost: string) { |
68 | this.existsSubject.next(nameWithHost) | 73 | this.existsSubject.next(nameWithHost) |
69 | 74 | ||
70 | return this.existsObservable | 75 | return this.existsObservable.pipe(first()) |
71 | } | 76 | } |
72 | 77 | ||
73 | private areSubscriptionExist (uris: string[]): Observable<SubscriptionExistResult> { | 78 | private areSubscriptionExist (uris: string[]): Observable<SubscriptionExistResult> { |
74 | console.log(uris) | ||
75 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL + '/exist' | 79 | const url = UserSubscriptionService.BASE_USER_SUBSCRIPTIONS_URL + '/exist' |
76 | let params = new HttpParams() | 80 | let params = new HttpParams() |
77 | 81 | ||
diff --git a/client/src/app/shared/video/infinite-scroller.directive.ts b/client/src/app/shared/video/infinite-scroller.directive.ts index 0448e2c23..4dc1f86e7 100644 --- a/client/src/app/shared/video/infinite-scroller.directive.ts +++ b/client/src/app/shared/video/infinite-scroller.directive.ts | |||
@@ -11,7 +11,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy { | |||
11 | @Input() containerHeight: number | 11 | @Input() containerHeight: number |
12 | @Input() pageHeight: number | 12 | @Input() pageHeight: number |
13 | @Input() percentLimit = 70 | 13 | @Input() percentLimit = 70 |
14 | @Input() autoLoading = false | 14 | @Input() autoInit = false |
15 | 15 | ||
16 | @Output() nearOfBottom = new EventEmitter<void>() | 16 | @Output() nearOfBottom = new EventEmitter<void>() |
17 | @Output() nearOfTop = new EventEmitter<void>() | 17 | @Output() nearOfTop = new EventEmitter<void>() |
@@ -29,7 +29,7 @@ export class InfiniteScrollerDirective implements OnInit, OnDestroy { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | ngOnInit () { | 31 | ngOnInit () { |
32 | if (this.autoLoading === true) return this.initialize() | 32 | if (this.autoInit === true) return this.initialize() |
33 | } | 33 | } |
34 | 34 | ||
35 | ngOnDestroy () { | 35 | ngOnDestroy () { |