aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-custom-markup
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-02 15:29:09 +0200
committerChocobozzz <me@florianbigard.com>2021-08-02 15:40:09 +0200
commit3da38d6e9f8d600476be276666ac7223aa5f172c (patch)
treedaec25cccb900a0f90fc9d2273099683b42d8551 /client/src/app/shared/shared-custom-markup
parent200eaf5152ca72fe6b05a49caf819e22bd045b37 (diff)
downloadPeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.gz
PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.zst
PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.zip
Fetch things in bulk for the homepage
Diffstat (limited to 'client/src/app/shared/shared-custom-markup')
-rw-r--r--client/src/app/shared/shared-custom-markup/custom-markup.service.ts18
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/channel-miniature-markup.component.ts7
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/playlist-miniature-markup.component.ts7
-rw-r--r--client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts5
-rw-r--r--client/src/app/shared/shared-custom-markup/shared-custom-markup.module.ts4
5 files changed, 23 insertions, 18 deletions
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 {
65 65
66 for (const selector of Object.keys(this.htmlBuilders)) { 66 for (const selector of Object.keys(this.htmlBuilders)) {
67 rootElement.querySelectorAll(selector) 67 rootElement.querySelectorAll(selector)
68 .forEach((e: HTMLElement) => { 68 .forEach((e: HTMLElement) => {
69 try { 69 try {
70 const element = this.execHTMLBuilder(selector, e) 70 const element = this.execHTMLBuilder(selector, e)
71 // Insert as first child 71 // Insert as first child
72 e.insertBefore(element, e.firstChild) 72 e.insertBefore(element, e.firstChild)
73 } catch (err) { 73 } catch (err) {
74 console.error('Cannot inject component %s.', selector, err) 74 console.error('Cannot inject component %s.', selector, err)
75 } 75 }
76 }) 76 })
77 } 77 }
78 78
79 const loadedPromises: Promise<boolean>[] = [] 79 const loadedPromises: Promise<boolean>[] = []
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'
2import { finalize, map, switchMap, tap } from 'rxjs/operators' 2import { finalize, map, switchMap, tap } from 'rxjs/operators'
3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 3import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
4import { MarkdownService, Notifier, UserService } from '@app/core' 4import { MarkdownService, Notifier, UserService } from '@app/core'
5import { FindInBulkService } from '@app/shared/shared-search'
5import { Video, VideoSortField } from '@shared/models/videos' 6import { Video, VideoSortField } from '@shared/models/videos'
6import { VideoChannel, VideoChannelService, VideoService } from '../../shared-main' 7import { VideoChannel, VideoService } from '../../shared-main'
7import { CustomMarkupComponent } from './shared' 8import { CustomMarkupComponent } from './shared'
8 9
9/* 10/*
@@ -29,14 +30,14 @@ export class ChannelMiniatureMarkupComponent implements CustomMarkupComponent, O
29 30
30 constructor ( 31 constructor (
31 private markdown: MarkdownService, 32 private markdown: MarkdownService,
32 private channelService: VideoChannelService, 33 private findInBulk: FindInBulkService,
33 private videoService: VideoService, 34 private videoService: VideoService,
34 private userService: UserService, 35 private userService: UserService,
35 private notifier: Notifier 36 private notifier: Notifier
36 ) { } 37 ) { }
37 38
38 ngOnInit () { 39 ngOnInit () {
39 this.channelService.getVideoChannel(this.name) 40 this.findInBulk.getChannel(this.name)
40 .pipe( 41 .pipe(
41 tap(channel => this.channel = channel), 42 tap(channel => this.channel = channel),
42 switchMap(() => from(this.markdown.textMarkdownToHTML(this.channel.description))), 43 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 @@
1import { finalize } from 'rxjs/operators' 1import { finalize } from 'rxjs/operators'
2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
3import { Notifier } from '@app/core' 3import { Notifier } from '@app/core'
4import { FindInBulkService } from '@app/shared/shared-search'
4import { MiniatureDisplayOptions } from '../../shared-video-miniature' 5import { MiniatureDisplayOptions } from '../../shared-video-miniature'
5import { VideoPlaylist, VideoPlaylistService } from '../../shared-video-playlist' 6import { VideoPlaylist } from '../../shared-video-playlist'
6import { CustomMarkupComponent } from './shared' 7import { CustomMarkupComponent } from './shared'
7 8
8/* 9/*
@@ -33,12 +34,12 @@ export class PlaylistMiniatureMarkupComponent implements CustomMarkupComponent,
33 } 34 }
34 35
35 constructor ( 36 constructor (
36 private playlistService: VideoPlaylistService, 37 private findInBulkService: FindInBulkService,
37 private notifier: Notifier 38 private notifier: Notifier
38 ) { } 39 ) { }
39 40
40 ngOnInit () { 41 ngOnInit () {
41 this.playlistService.getVideoPlaylist(this.uuid) 42 this.findInBulkService.getPlaylist(this.uuid)
42 .pipe(finalize(() => this.loaded.emit(true))) 43 .pipe(finalize(() => this.loaded.emit(true)))
43 .subscribe( 44 .subscribe(
44 playlist => this.playlist = playlist, 45 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'
4import { Video, VideoService } from '../../shared-main' 4import { Video, VideoService } from '../../shared-main'
5import { MiniatureDisplayOptions } from '../../shared-video-miniature' 5import { MiniatureDisplayOptions } from '../../shared-video-miniature'
6import { CustomMarkupComponent } from './shared' 6import { CustomMarkupComponent } from './shared'
7import { FindInBulkService } from '@app/shared/shared-search'
7 8
8/* 9/*
9 * Markup component that creates a video miniature only 10 * Markup component that creates a video miniature only
@@ -35,7 +36,7 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
35 36
36 constructor ( 37 constructor (
37 private auth: AuthService, 38 private auth: AuthService,
38 private videoService: VideoService, 39 private findInBulk: FindInBulkService,
39 private notifier: Notifier 40 private notifier: Notifier
40 ) { } 41 ) { }
41 42
@@ -50,7 +51,7 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
50 } 51 }
51 } 52 }
52 53
53 this.videoService.getVideo({ videoId: this.uuid }) 54 this.findInBulk.getVideo(this.uuid)
54 .pipe(finalize(() => this.loaded.emit(true))) 55 .pipe(finalize(() => this.loaded.emit(true)))
55 .subscribe( 56 .subscribe(
56 video => this.video = video, 57 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'
3import { SharedActorImageModule } from '../shared-actor-image/shared-actor-image.module' 3import { SharedActorImageModule } from '../shared-actor-image/shared-actor-image.module'
4import { SharedGlobalIconModule } from '../shared-icons' 4import { SharedGlobalIconModule } from '../shared-icons'
5import { SharedMainModule } from '../shared-main' 5import { SharedMainModule } from '../shared-main'
6import { SharedSearchModule } from '../shared-search'
6import { SharedVideoMiniatureModule } from '../shared-video-miniature' 7import { SharedVideoMiniatureModule } from '../shared-video-miniature'
7import { SharedVideoPlaylistModule } from '../shared-video-playlist' 8import { SharedVideoPlaylistModule } from '../shared-video-playlist'
8import { CustomMarkupContainerComponent } from './custom-markup-container.component' 9import { CustomMarkupContainerComponent } from './custom-markup-container.component'
@@ -26,7 +27,8 @@ import {
26 SharedGlobalIconModule, 27 SharedGlobalIconModule,
27 SharedVideoMiniatureModule, 28 SharedVideoMiniatureModule,
28 SharedVideoPlaylistModule, 29 SharedVideoPlaylistModule,
29 SharedActorImageModule 30 SharedActorImageModule,
31 SharedSearchModule
30 ], 32 ],
31 33
32 declarations: [ 34 declarations: [