aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-15 15:58:10 +0100
committerChocobozzz <me@florianbigard.com>2021-12-16 10:08:55 +0100
commita9bfa85d2cdf13670aaced740da5b493fbeddfce (patch)
tree3781c9218d4cc7786b6589365c0efbed2151703d /client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts
parentc77fdc605b3ccc1ab6890f889d8200fbe9372949 (diff)
downloadPeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.gz
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.tar.zst
PeerTube-a9bfa85d2cdf13670aaced740da5b493fbeddfce.zip
Add ability for admins to set default p2p policy
Diffstat (limited to 'client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts')
-rw-r--r--client/src/app/+videos/+video-watch/shared/recommendations/recommended-videos.component.ts27
1 files changed, 7 insertions, 20 deletions
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 dfc296d15..97f742499 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,10 +1,9 @@
1import { Observable } from 'rxjs' 1import { Observable } from 'rxjs'
2import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 2import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
3import { AuthService, Notifier, SessionStorageService, 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'
6import { VideoPlaylist } from '@app/shared/shared-video-playlist' 6import { VideoPlaylist } from '@app/shared/shared-video-playlist'
7import { UserLocalStorageKeys } from '@root-helpers/users'
8import { RecommendationInfo } from './recommendation-info.model' 7import { RecommendationInfo } from './recommendation-info.model'
9import { RecommendedVideosStore } from './recommended-videos.store' 8import { RecommendedVideosStore } from './recommended-videos.store'
10 9
@@ -39,24 +38,14 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
39 private userService: UserService, 38 private userService: UserService,
40 private authService: AuthService, 39 private authService: AuthService,
41 private notifier: Notifier, 40 private notifier: Notifier,
42 private store: RecommendedVideosStore, 41 private store: RecommendedVideosStore
43 private sessionStorageService: SessionStorageService
44 ) { 42 ) {
45 this.videos$ = this.store.recommendations$ 43 this.videos$ = this.store.recommendations$
46 this.hasVideos$ = this.store.hasRecommendations$ 44 this.hasVideos$ = this.store.hasRecommendations$
47 this.videos$.subscribe(videos => this.gotRecommendations.emit(videos)) 45 this.videos$.subscribe(videos => this.gotRecommendations.emit(videos))
48 46
49 if (this.authService.isLoggedIn()) { 47 this.userService.getAnonymousOrLoggedUser()
50 this.autoPlayNextVideo = this.authService.getUser().autoPlayNextVideo 48 .subscribe(user => this.autoPlayNextVideo = user.autoPlayNextVideo)
51 } else {
52 this.autoPlayNextVideo = this.sessionStorageService.getItem(UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true'
53
54 this.sessionStorageService.watch([ UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO ]).subscribe(
55 () => {
56 this.autoPlayNextVideo = this.sessionStorageService.getItem(UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true'
57 }
58 )
59 }
60 49
61 this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.` 50 this.autoPlayNextVideoTooltip = $localize`When active, the next video is automatically played after the current one.`
62 } 51 }
@@ -77,13 +66,9 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
77 } 66 }
78 67
79 switchAutoPlayNextVideo () { 68 switchAutoPlayNextVideo () {
80 this.sessionStorageService.setItem(UserLocalStorageKeys.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO, this.autoPlayNextVideo.toString()) 69 const details = { autoPlayNextVideo: this.autoPlayNextVideo }
81 70
82 if (this.authService.isLoggedIn()) { 71 if (this.authService.isLoggedIn()) {
83 const details = {
84 autoPlayNextVideo: this.autoPlayNextVideo
85 }
86
87 this.userService.updateMyProfile(details) 72 this.userService.updateMyProfile(details)
88 .subscribe({ 73 .subscribe({
89 next: () => { 74 next: () => {
@@ -92,6 +77,8 @@ export class RecommendedVideosComponent implements OnInit, OnChanges {
92 77
93 error: err => this.notifier.error(err.message) 78 error: err => this.notifier.error(err.message)
94 }) 79 })
80 } else {
81 this.userService.updateMyAnonymousProfile(details)
95 } 82 }
96 } 83 }
97} 84}