From 3da38d6e9f8d600476be276666ac7223aa5f172c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 2 Aug 2021 15:29:09 +0200 Subject: Fetch things in bulk for the homepage --- .../shared-custom-markup/custom-markup.service.ts | 18 +++++++++--------- .../channel-miniature-markup.component.ts | 7 ++++--- .../playlist-miniature-markup.component.ts | 7 ++++--- .../video-miniature-markup.component.ts | 5 +++-- .../shared-custom-markup.module.ts | 4 +++- 5 files changed, 23 insertions(+), 18 deletions(-) (limited to 'client/src/app/shared/shared-custom-markup') diff --git a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts index 231e52d0a..089728a51 100644 --- a/client/src/app/shared/shared-custom-markup/custom-markup.service.ts +++ b/client/src/app/shared/shared-custom-markup/custom-markup.service.ts @@ -65,15 +65,15 @@ export class CustomMarkupService { for (const selector of Object.keys(this.htmlBuilders)) { rootElement.querySelectorAll(selector) - .forEach((e: HTMLElement) => { - try { - const element = this.execHTMLBuilder(selector, e) - // Insert as first child - e.insertBefore(element, e.firstChild) - } catch (err) { - console.error('Cannot inject component %s.', selector, err) - } - }) + .forEach((e: HTMLElement) => { + try { + const element = this.execHTMLBuilder(selector, e) + // Insert as first child + e.insertBefore(element, e.firstChild) + } catch (err) { + console.error('Cannot inject component %s.', selector, err) + } + }) } const loadedPromises: Promise[] = [] diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts index 7043a7ec9..bb099deae 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts @@ -2,8 +2,9 @@ import { from } from 'rxjs' import { finalize, map, switchMap, tap } from 'rxjs/operators' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { MarkdownService, Notifier, UserService } from '@app/core' +import { FindInBulkService } from '@app/shared/shared-search' import { Video, VideoSortField } from '@shared/models/videos' -import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main' +import { VideoChannel, VideoService } from '../../shared-main' import { CustomMarkupComponent } from './shared' /* @@ -29,14 +30,14 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O constructor ( private markdown: MarkdownService, - private channelService: VideoChannelService, + private findInBulk: FindInBulkService, private videoService: VideoService, private userService: UserService, private notifier: Notifier ) { } ngOnInit () { - this.channelService.getVideoChannel(this.name) + this.findInBulk.getChannel(this.name) .pipe( tap(channel => this.channel = channel), switchMap(() => from(this.markdown.textMarkdownToHTML(this.channel.description))), diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts index ff8cc01db..97d31c4a7 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts @@ -1,8 +1,9 @@ import { finalize } from 'rxjs/operators' import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { Notifier } from '@app/core' +import { FindInBulkService } from '@app/shared/shared-search' import { MiniatureDisplayOptions } from '../../shared-video-miniature' -import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist' +import { VideoPlaylist } from '../../shared-video-playlist' import { CustomMarkupComponent } from './shared' /* @@ -33,12 +34,12 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent, } constructor ( - private playlistService: VideoPlaylistService, + private findInBulkService: FindInBulkService, private notifier: Notifier ) { } ngOnInit () { - this.playlistService.getVideoPlaylist(this.uuid) + this.findInBulkService.getPlaylist(this.uuid) .pipe(finalize(() => this.loaded.emit(true))) .subscribe( playlist => this.playlist = playlist, diff --git a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts index 47518abfd..ba61aaf51 100644 --- a/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts +++ b/client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts @@ -4,6 +4,7 @@ import { AuthService, Notifier } from '@app/core' import { Video, VideoService } from '../../shared-main' import { MiniatureDisplayOptions } from '../../shared-video-miniature' import { CustomMarkupComponent } from './shared' +import { FindInBulkService } from '@app/shared/shared-search' /* * Markup component that creates a video miniature only @@ -35,7 +36,7 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI constructor ( private auth: AuthService, - private videoService: VideoService, + private findInBulk: FindInBulkService, private notifier: Notifier ) { } @@ -50,7 +51,7 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI } } - this.videoService.getVideo({ videoId: this.uuid }) + this.findInBulk.getVideo(this.uuid) .pipe(finalize(() => this.loaded.emit(true))) .subscribe( video => this.video = video, diff --git a/client/src/app/shared/shared-custom-markup/shared-custom-markup.module.ts b/client/src/app/shared/shared-custom-markup/shared-custom-markup.module.ts index dccd64709..27e976d13 100644 --- a/client/src/app/shared/shared-custom-markup/shared-custom-markup.module.ts +++ b/client/src/app/shared/shared-custom-markup/shared-custom-markup.module.ts @@ -3,6 +3,7 @@ import { NgModule } from '@angular/core' import { SharedActorImageModule } from '../shared-actor-image/shared-actor-image.module' import { SharedGlobalIconModule } from '../shared-icons' import { SharedMainModule } from '../shared-main' +import { SharedSearchModule } from '../shared-search' import { SharedVideoMiniatureModule } from '../shared-video-miniature' import { SharedVideoPlaylistModule } from '../shared-video-playlist' import { CustomMarkupContainerComponent } from './custom-markup-container.component' @@ -26,7 +27,8 @@ import { SharedGlobalIconModule, SharedVideoMiniatureModule, SharedVideoPlaylistModule, - SharedActorImageModule + SharedActorImageModule, + SharedSearchModule ], declarations: [ -- cgit v1.2.3