pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = {
common: new ReplaySubject<boolean>(1),
+ search: new ReplaySubject<boolean>(1),
'video-watch': new ReplaySubject<boolean>(1)
}
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<any>[] = []
for (const pluginInfo of toLoad) {
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',
private notifier: Notifier,
private searchService: SearchService,
private authService: AuthService,
- private hooks: HooksService
+ private hooks: HooksService,
+ private pluginService: PluginService
) { }
get user () {
}
ngOnInit () {
+ this.pluginService.loadPluginsByScope('search')
+
this.subActivatedRoute = this.route.queryParams.subscribe(
queryParams => {
const querySearch = queryParams['search']
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'
)
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'
)
videoId: number | string,
componentPagination: ComponentPagination,
sort: VideoSortField
- }): Observable<{ comments: VideoComment[], totalComments: number}> {
+ }): Observable<ResultList<VideoComment>> {
const { videoId, componentPagination, sort } = parameters
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
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<ResultList<VideoComment>>(url, { params })
.pipe(
- map(this.extractVideoComments),
+ map(result => this.extractVideoComments(result)),
catchError(err => this.restExtractor.handleError(err))
)
}
comments.push(new VideoComment(videoCommentJson))
}
- return { comments, totalComments }
+ return { data: comments, total: totalComments }
}
private extractVideoCommentTree (tree: VideoCommentThreadTree) {
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)
}
async ngOnInit () {
- await this.pluginService.loadPluginsByScope('video-watch')
+ this.pluginService.loadPluginsByScope('video-watch')
this.configSub = this.serverService.configLoaded
.subscribe(() => {
-export type PluginClientScope = 'common' | 'video-watch'
+export type PluginClientScope = 'common' | 'video-watch' | 'search'
+import { PluginClientScope } from './plugin-client-scope.type'
+
export type ClientScript = {
script: string,
- scopes: string[]
+ scopes: PluginClientScope[]
}
export type PluginPackageJson = {
import { NSFWPolicyType } from '../videos/nsfw-policy.type'
import { ClientScript } from '../plugins/plugin-package-json.model'
-import { PluginClientScope } from '../plugins/plugin-scope.type'
export interface ServerConfigPlugin {
name: string
version: string
description: string
- clientScripts: { [name in PluginClientScope]: ClientScript }
+ clientScripts: { [name: string]: ClientScript }
}
export interface ServerConfigTheme extends ServerConfigPlugin {