]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-custom-markup/peertube-custom-tags/video-miniature-markup.component.ts
Deprecate filter video query
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-custom-markup / peertube-custom-tags / video-miniature-markup.component.ts
index 6ee5123e0e673fef015efeb0e1933e3745b8d1ec..cbbacf77c65d6833b14553c6a1424d97b158ced7 100644 (file)
@@ -1,6 +1,8 @@
+import { finalize } from 'rxjs/operators'
 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
-import { AuthService } from '@app/core'
-import { Video, VideoService } from '../../shared-main'
+import { AuthService, Notifier } from '@app/core'
+import { FindInBulkService } from '@app/shared/shared-search'
+import { Video } from '../../shared-main'
 import { MiniatureDisplayOptions } from '../../shared-video-miniature'
 import { CustomMarkupComponent } from './shared'
 
@@ -16,11 +18,10 @@ import { CustomMarkupComponent } from './shared'
 export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnInit {
   @Input() uuid: string
   @Input() onlyDisplayTitle: boolean
+  @Input() video: Video
 
   @Output() loaded = new EventEmitter<boolean>()
 
-  video: Video
-
   displayOptions: MiniatureDisplayOptions = {
     date: true,
     views: true,
@@ -34,7 +35,8 @@ export class VideoMiniatureMarkupComponent implements CustomMarkupComponent, OnI
 
   constructor (
     private auth: AuthService,
-    private videoService: VideoService
+    private findInBulk: FindInBulkService,
+    private notifier: Notifier
   ) { }
 
   getUser () {
@@ -48,11 +50,14 @@ 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({
         next: video => this.video = video,
 
-        complete: () => this.loaded.emit(true)
+        error: err => this.notifier.error($localize`Error in video miniature component: ${err.message}`)
       })
   }
 }