From e8f902c05cb35f6d5e9b75a23ddabd51c220a976 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 22 Jul 2019 16:04:44 +0200 Subject: Use search client scope --- client/src/app/core/plugins/plugin.service.ts | 7 ++++++- client/src/app/search/search.component.ts | 10 +++++++--- .../app/videos/+video-watch/comment/video-comment.service.ts | 9 ++++----- .../videos/+video-watch/comment/video-comments.component.ts | 4 ++-- client/src/app/videos/+video-watch/video-watch.component.ts | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) (limited to 'client/src') diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 14310f093..7c1d69bec 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts @@ -28,6 +28,7 @@ export class PluginService implements ClientHook { pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject } = { common: new ReplaySubject(1), + search: new ReplaySubject(1), 'video-watch': new ReplaySubject(1) } @@ -109,7 +110,11 @@ export class PluginService implements ClientHook { if (!isReload) this.loadedScopes.push(scope) const toLoad = this.scopes[ scope ] - if (!Array.isArray(toLoad)) return + if (!Array.isArray(toLoad)) { + this.pluginsLoaded[scope].next(true) + + return + } const promises: Promise[] = [] for (const pluginInfo of toLoad) { diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index b1d732d68..55637771e 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts @@ -11,6 +11,7 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model' import { immutableAssign } from '@app/shared/misc/utils' import { Video } from '@app/shared/video/video.model' import { HooksService } from '@app/core/plugins/hooks.service' +import { PluginService } from '@app/core/plugins/plugin.service' @Component({ selector: 'my-search', @@ -43,7 +44,8 @@ export class SearchComponent implements OnInit, OnDestroy { private notifier: Notifier, private searchService: SearchService, private authService: AuthService, - private hooks: HooksService + private hooks: HooksService, + private pluginService: PluginService ) { } get user () { @@ -51,6 +53,8 @@ export class SearchComponent implements OnInit, OnDestroy { } ngOnInit () { + this.pluginService.loadPluginsByScope('search') + this.subActivatedRoute = this.route.queryParams.subscribe( queryParams => { const querySearch = queryParams['search'] @@ -175,7 +179,7 @@ export class SearchComponent implements OnInit, OnDestroy { return this.hooks.wrapObsFun( this.searchService.searchVideos.bind(this.searchService), params, - 'common', + 'search', 'filter:api.search.videos.list.params', 'filter:api.search.videos.list.result' ) @@ -190,7 +194,7 @@ export class SearchComponent implements OnInit, OnDestroy { return this.hooks.wrapObsFun( this.searchService.searchVideoChannels.bind(this.searchService), params, - 'common', + 'search', 'filter:api.search.video-channels.list.params', 'filter:api.search.video-channels.list.result' ) diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index eb608a1a3..550d42fa8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -52,7 +52,7 @@ export class VideoCommentService { videoId: number | string, componentPagination: ComponentPagination, sort: VideoSortField - }): Observable<{ comments: VideoComment[], totalComments: number}> { + }): Observable> { const { videoId, componentPagination, sort } = parameters const pagination = this.restService.componentPaginationToRestPagination(componentPagination) @@ -61,10 +61,9 @@ export class VideoCommentService { params = this.restService.addRestGetParams(params, pagination, sort) const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' - return this.authHttp - .get(url, { params }) + return this.authHttp.get>(url, { params }) .pipe( - map(this.extractVideoComments), + map(result => this.extractVideoComments(result)), catchError(err => this.restExtractor.handleError(err)) ) } @@ -136,7 +135,7 @@ export class VideoCommentService { comments.push(new VideoComment(videoCommentJson)) } - return { comments, totalComments } + return { data: comments, total: totalComments } } private extractVideoCommentTree (tree: VideoCommentThreadTree) { diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 3c1a0986c..5bafc55e5 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -122,8 +122,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { obs.subscribe( res => { - this.comments = this.comments.concat(res.comments) - this.componentPagination.totalItems = res.totalComments + this.comments = this.comments.concat(res.data) + this.componentPagination.totalItems = res.total }, err => this.notifier.error(err.message) diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index eed2ec048..0d9b6d680 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -103,7 +103,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } async ngOnInit () { - await this.pluginService.loadPluginsByScope('video-watch') + this.pluginService.loadPluginsByScope('video-watch') this.configSub = this.serverService.configLoaded .subscribe(() => { -- cgit v1.2.3