aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src
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
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')
-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
-rw-r--r--client/src/app/core/users/user-local-storage.service.ts1
3 files changed, 22 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 }
diff --git a/client/src/app/core/users/user-local-storage.service.ts b/client/src/app/core/users/user-local-storage.service.ts
index d5fd1e447..1e629249a 100644
--- a/client/src/app/core/users/user-local-storage.service.ts
+++ b/client/src/app/core/users/user-local-storage.service.ts
@@ -168,6 +168,7 @@ export class UserLocalStorageService {
168 UserLocalStorageKeys.NSFW_POLICY, 168 UserLocalStorageKeys.NSFW_POLICY,
169 UserLocalStorageKeys.P2P_ENABLED, 169 UserLocalStorageKeys.P2P_ENABLED,
170 UserLocalStorageKeys.AUTO_PLAY_VIDEO, 170 UserLocalStorageKeys.AUTO_PLAY_VIDEO,
171 UserLocalStorageKeys.AUTO_PLAY_NEXT_VIDEO,
171 UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST, 172 UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST,
172 UserLocalStorageKeys.THEME, 173 UserLocalStorageKeys.THEME,
173 UserLocalStorageKeys.VIDEO_LANGUAGES 174 UserLocalStorageKeys.VIDEO_LANGUAGES