]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
Add ability for admins to set default p2p policy
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / shared / information / privacy-concerns.component.ts
CommitLineData
5196817c 1import { Component, Input, OnInit } from '@angular/core'
a9bfa85d 2import { ServerService, User, UserService } from '@app/core'
6ebdd12f 3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
5196817c 4import { HTMLServerConfig, Video } from '@shared/models'
a9bfa85d 5import { isP2PEnabled } from '../../../../../assets/player/utils'
6ebdd12f
C
6
7@Component({
8 selector: 'my-privacy-concerns',
9 templateUrl: './privacy-concerns.component.html',
10 styleUrls: [ './privacy-concerns.component.scss' ]
11})
12export class PrivacyConcernsComponent implements OnInit {
13 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
14
5196817c
C
15 @Input() video: Video
16
a9bfa85d 17 display = false
6ebdd12f
C
18
19 private serverConfig: HTMLServerConfig
20
21 constructor (
a9bfa85d
C
22 private serverService: ServerService,
23 private userService: UserService
6ebdd12f
C
24 ) { }
25
98ab5dc8 26 ngOnInit () {
6ebdd12f 27 this.serverConfig = this.serverService.getHTMLConfig()
98ab5dc8 28
a9bfa85d
C
29 this.userService.getAnonymousOrLoggedUser()
30 .subscribe(user => this.updateDisplay(user))
6ebdd12f
C
31 }
32
6ebdd12f
C
33 acceptedPrivacyConcern () {
34 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
5196817c 35
a9bfa85d 36 this.display = false
5196817c
C
37 }
38
a9bfa85d
C
39 private updateDisplay (user: User) {
40 if (isP2PEnabled(this.video, this.serverConfig, user.p2pEnabled) && !this.alreadyAccepted()) {
41 this.display = true
42 }
5196817c
C
43 }
44
45 private alreadyAccepted () {
46 return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
6ebdd12f
C
47 }
48}