mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2024-10-27 14:39:32 +03:00
Fix live update of autoplay next video
This commit is contained in:
parent
e81d45b4cb
commit
6a7cea1527
@ -14,7 +14,7 @@
|
|||||||
<ng-container *ngFor="let video of (videos$ | async); let i = index; let length = count">
|
<ng-container *ngFor="let video of (videos$ | async); let i = index; let length = count">
|
||||||
<span i18n *ngIf="!playlist && i === 0 && length !== 0 && autoPlayNextVideo" class="title-page-next-video-label">Next video to be played</span>
|
<span i18n *ngIf="!playlist && i === 0 && length !== 0 && autoPlayNextVideo" class="title-page-next-video-label">Next video to be played</span>
|
||||||
<my-video-miniature
|
<my-video-miniature
|
||||||
[displayOptions]="displayOptions" [video]="video" [user]="userMiniature" [displayAsRow]="displayAsRow"
|
[displayOptions]="displayOptions" [video]="video" [user]="user" [displayAsRow]="displayAsRow"
|
||||||
(videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (videoAccountMuted)="onVideoRemoved()"
|
(videoBlocked)="onVideoRemoved()" (videoRemoved)="onVideoRemoved()" (videoAccountMuted)="onVideoRemoved()"
|
||||||
actorImageSize="32"
|
actorImageSize="32"
|
||||||
>
|
>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Observable } from 'rxjs'
|
import { Observable, startWith, Subscription, switchMap } from 'rxjs'
|
||||||
import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
|
import { Component, EventEmitter, Input, OnChanges, OnDestroy, OnInit, Output } from '@angular/core'
|
||||||
import { AuthService, Notifier, User, UserService } from '@app/core'
|
import { AuthService, Notifier, User, UserService } from '@app/core'
|
||||||
import { Video } from '@app/shared/shared-main'
|
import { Video } from '@app/shared/shared-main'
|
||||||
import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
|
import { MiniatureDisplayOptions } from '@app/shared/shared-video-miniature'
|
||||||
@ -12,7 +12,7 @@ import { RecommendedVideosStore } from './recommended-videos.store'
|
|||||||
templateUrl: './recommended-videos.component.html',
|
templateUrl: './recommended-videos.component.html',
|
||||||
styleUrls: [ './recommended-videos.component.scss' ]
|
styleUrls: [ './recommended-videos.component.scss' ]
|
||||||
})
|
})
|
||||||
export class RecommendedVideosComponent implements OnInit, OnChanges {
|
export class RecommendedVideosComponent implements OnInit, OnChanges, OnDestroy {
|
||||||
@Input() inputRecommendation: RecommendationInfo
|
@Input() inputRecommendation: RecommendationInfo
|
||||||
@Input() playlist: VideoPlaylist
|
@Input() playlist: VideoPlaylist
|
||||||
@Input() displayAsRow: boolean
|
@Input() displayAsRow: boolean
|
||||||
@ -29,7 +29,9 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
|
|||||||
avatar: true
|
avatar: true
|
||||||
}
|
}
|
||||||
|
|
||||||
userMiniature: User
|
user: User
|
||||||
|
|
||||||
|
private userSub: Subscription
|
||||||
|
|
||||||
readonly hasVideos$: Observable<boolean>
|
readonly hasVideos$: Observable<boolean>
|
||||||
readonly videos$: Observable<Video[]>
|
readonly videos$: Observable<Video[]>
|
||||||
@ -44,15 +46,20 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
|
|||||||
this.hasVideos$ = this.store.hasRecommendations$
|
this.hasVideos$ = this.store.hasRecommendations$
|
||||||
this.videos$.subscribe(videos => this.gotRecommendations.emit(videos))
|
this.videos$.subscribe(videos => this.gotRecommendations.emit(videos))
|
||||||
|
|
||||||
this.userService.getAnonymousOrLoggedUser()
|
|
||||||
.subscribe(user => this.autoPlayNextVideo = user.autoPlayNextVideo)
|
|
||||||
|
|
||||||
this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.`
|
this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.`
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit () {
|
ngOnInit () {
|
||||||
this.userService.getAnonymousOrLoggedUser()
|
this.userSub = this.userService.listenAnonymousUpdate()
|
||||||
.subscribe(user => this.userMiniature = user)
|
.pipe(
|
||||||
|
startWith(true),
|
||||||
|
switchMap(() => this.userService.getAnonymousOrLoggedUser())
|
||||||
|
)
|
||||||
|
.subscribe(user => {
|
||||||
|
this.user = user
|
||||||
|
this.autoPlayNextVideo = user.autoPlayNextVideo
|
||||||
|
console.log(this.autoPlayNextVideo)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges () {
|
ngOnChanges () {
|
||||||
@ -61,6 +68,10 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (this.userSub) this.userSub.unsubscribe()
|
||||||
|
}
|
||||||
|
|
||||||
onVideoRemoved () {
|
onVideoRemoved () {
|
||||||
this.store.requestNewRecommendations(this.inputRecommendation)
|
this.store.requestNewRecommendations(this.inputRecommendation)
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,7 @@ export class UserLocalStorageService {
|
|||||||
UserLocalStorageKeys.NSFW_POLICY,
|
UserLocalStorageKeys.NSFW_POLICY,
|
||||||
UserLocalStorageKeys.P2P_ENABLED,
|
UserLocalStorageKeys.P2P_ENABLED,
|
||||||
UserLocalStorageKeys.AUTO_PLAY_VIDEO,
|
UserLocalStorageKeys.AUTO_PLAY_VIDEO,
|
||||||
|
UserLocalStorageKeys.AUTO_PLAY_NEXT_VIDEO,
|
||||||
UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST,
|
UserLocalStorageKeys.AUTO_PLAY_VIDEO_PLAYLIST,
|
||||||
UserLocalStorageKeys.THEME,
|
UserLocalStorageKeys.THEME,
|
||||||
UserLocalStorageKeys.VIDEO_LANGUAGES
|
UserLocalStorageKeys.VIDEO_LANGUAGES
|
||||||
|
Loading…
Reference in New Issue
Block a user