X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fshared%2Fshared-custom-markup%2Fpeertube-custom-tags%2Fvideo-miniature-markup.component.ts;h=21774b7aadc1c05d4bb275cf4e11bee82dff824c;hb=647c2b7d0448e68d8c8ade52d9568e9b33f8638d;hp=47518abfdc11d17ef9dd3662ed75c623daa22f95;hpb=cf21b2cbef61929177b9c09b5e017c3b7eb8535d;p=github%2FChocobozzz%2FPeerTube.git 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..21774b7aa 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 @@ -1,7 +1,8 @@ import { finalize } from 'rxjs/operators' -import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core' +import { ChangeDetectionStrategy, ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output } from '@angular/core' import { AuthService, Notifier } from '@app/core' -import { Video, VideoService } from '../../shared-main' +import { FindInBulkService } from '@app/shared/shared-search' +import { Video } from '../../shared-main' import { MiniatureDisplayOptions } from '../../shared-video-miniature' import { CustomMarkupComponent } from './shared' @@ -12,16 +13,16 @@ import { CustomMarkupComponent } from './shared' @Component({ selector: 'my-video-miniature-markup', templateUrl: 'video-miniature-markup.component.html', - styleUrls: [ 'video-miniature-markup.component.scss' ] + styleUrls: [ 'video-miniature-markup.component.scss' ], + changeDetection: ChangeDetectionStrategy.OnPush }) export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit { @Input() uuid: string @Input() onlyDisplayTitle: boolean + @Input() video: Video @Output() loaded = new EventEmitter() - video: Video - displayOptions: MiniatureDisplayOptions = { date: true, views: true, @@ -35,8 +36,9 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI constructor ( private auth: AuthService, - private videoService: VideoService, - private notifier: Notifier + private findInBulk: FindInBulkService, + private notifier: Notifier, + private cd: ChangeDetectorRef ) { } getUser () { @@ -50,12 +52,17 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI } } - this.videoService.getVideo({ videoId: this.uuid }) + if (this.video) return + + this.findInBulk.getVideo(this.uuid) .pipe(finalize(() => this.loaded.emit(true))) - .subscribe( - video => this.video = video, + .subscribe({ + next: video => { + this.video = video + this.cd.markForCheck() + }, - err => this.notifier.error('Error in video miniature component: ' + err.message) - ) + error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`) + }) } }