aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-02-15 11:32:08 +0100
committerChocobozzz <me@florianbigard.com>2023-02-15 11:32:08 +0100
commit6a7cea15271cf30c4b06c7981bff5201978337e8 (patch)
tree90fda9efcd412696be0f2da3597803ddc1afa4c2 /client/src/app/+videos/+video-watch
parente81d45b4cb6462029661a525315529b02261722d (diff)
downloadPeerTube-6a7cea15271cf30c4b06c7981bff5201978337e8.tar.gz
PeerTube-6a7cea15271cf30c4b06c7981bff5201978337e8.tar.zst
PeerTube-6a7cea15271cf30c4b06c7981bff5201978337e8.zip
Fix live update of autoplay next video
Diffstat (limited to 'client/src/app/+videos/+video-watch')
-rw-r--r--client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html2
-rw-r--r--client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts29
2 files changed, 21 insertions, 10 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html
index 5ac801622..2bbe26c96 100644
--- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html
+++ b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.html
@@ -14,7 +14,7 @@
14 <ng-container *ngFor="let video of (videos$ | async); let i = index; let length = count"> 14 <ng-container *ngFor="let video of (videos$ | async); let i = index; let length = count">
15 <span i18n *ngIf="!playlist && i === 0 && length !== 0 && autoPlayNextVideo" class="title-page-next-video-label">Next video to be played</span> 15 <span i18n *ngIf="!playlist && i === 0 && length !== 0 && autoPlayNextVideo" class="title-page-next-video-label">Next video to be played</span>
16 <my-video-miniature 16 <my-video-miniature
17 [displayOptions]="displayOptions" [video]="video" [user]="userMiniature" [displayAsRow]="displayAsRow" 17 [displayOptions]="displayOptions" [video]="video" [user]="user" [displayAsRow]="displayAsRow"
18 (videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (videoAccountMuted)="onVideoRemoved()" 18 (videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (videoAccountMuted)="onVideoRemoved()"
19 actorImageSize="32" 19 actorImageSize="32"
20 > 20 >
diff --git a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
index 97f742499..426f5d622 100644
--- a/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
@@ -1,5 +1,5 @@
1import { Observable } from 'rxjs' 1import { Observable, startWith, Subscription, switchMap } from 'rxjs'
2import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output } from '@angular/core'
3import { AuthService, Notifier, User, UserService } from '@app/core' 3import { AuthService, Notifier, User, UserService } from '@app/core'
4import { Video } from '@app/shared/shared-main' 4import { Video } from '@app/shared/shared-main'
5import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature' 5import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
@@ -12,7 +12,7 @@ import { RecommendedVideosStore } from './recommended-videos.store'
12 templateUrl: './recommended-videos.component.html', 12 templateUrl: './recommended-videos.component.html',
13 styleUrls: [ './recommended-videos.component.scss' ] 13 styleUrls: [ './recommended-videos.component.scss' ]
14}) 14})
15export class RecommendedVideosComponent implements OnInit, OnChanges { 15export class RecommendedVideosComponent implements OnInit, OnChanges, OnDestroy {
16 @Input() inputRecommendation: RecommendationInfo 16 @Input() inputRecommendation: RecommendationInfo
17 @Input() playlist: VideoPlaylist 17 @Input() playlist: VideoPlaylist
18 @Input() displayAsRow: boolean 18 @Input() displayAsRow: boolean
@@ -29,7 +29,9 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
29 avatar: true 29 avatar: true
30 } 30 }
31 31
32 userMiniature: User 32 user: User
33
34 private userSub: Subscription
33 35
34 readonly hasVideos$: Observable<boolean> 36 readonly hasVideos$: Observable<boolean>
35 readonly videos$: Observable<Video[]> 37 readonly videos$: Observable<Video[]>
@@ -44,15 +46,20 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
44 this.hasVideos$ = this.store.hasRecommendations$ 46 this.hasVideos$ = this.store.hasRecommendations$
45 this.videos$.subscribe(videos => this.gotRecommendations.emit(videos)) 47 this.videos$.subscribe(videos => this.gotRecommendations.emit(videos))
46 48
47 this.userService.getAnonymousOrLoggedUser()
48 .subscribe(user => this.autoPlayNextVideo = user.autoPlayNextVideo)
49
50 this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.` 49 this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.`
51 } 50 }
52 51
53 ngOnInit () { 52 ngOnInit () {
54 this.userService.getAnonymousOrLoggedUser() 53 this.userSub = this.userService.listenAnonymousUpdate()
55 .subscribe(user => this.userMiniature = user) 54 .pipe(
55 startWith(true),
56 switchMap(() => this.userService.getAnonymousOrLoggedUser())
57 )
58 .subscribe(user => {
59 this.user = user
60 this.autoPlayNextVideo = user.autoPlayNextVideo
61 console.log(this.autoPlayNextVideo)
62 })
56 } 63 }
57 64
58 ngOnChanges () { 65 ngOnChanges () {
@@ -61,6 +68,10 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
61 } 68 }
62 } 69 }
63 70
71 ngOnDestroy(): void {
72 if (this.userSub) this.userSub.unsubscribe()
73 }
74
64 onVideoRemoved () { 75 onVideoRemoved () {
65 this.store.requestNewRecommendations(this.inputRecommendation) 76 this.store.requestNewRecommendations(this.inputRecommendation)
66 } 77 }