]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
Fix privacy concern for remote videos
[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'
6ebdd12f
C
2import { ServerService } from '@app/core'
3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
5196817c 4import { HTMLServerConfig, Video } from '@shared/models'
6ebdd12f
C
5import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage'
6import { isWebRTCDisabled } from '../../../../../assets/player/utils'
7
8@Component({
9 selector: 'my-privacy-concerns',
10 templateUrl: './privacy-concerns.component.html',
11 styleUrls: [ './privacy-concerns.component.scss' ]
12})
13export class PrivacyConcernsComponent implements OnInit {
14 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
15
5196817c
C
16 @Input() video: Video
17
18 display = true
6ebdd12f
C
19
20 private serverConfig: HTMLServerConfig
21
22 constructor (
23 private serverService: ServerService
24 ) { }
25
98ab5dc8 26 ngOnInit () {
6ebdd12f 27 this.serverConfig = this.serverService.getHTMLConfig()
98ab5dc8 28
5196817c
C
29 if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) {
30 this.display = false
6ebdd12f
C
31 }
32 }
33
6ebdd12f
C
34 acceptedPrivacyConcern () {
35 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
5196817c
C
36 this.display = false
37 }
38
39 private isTrackerDisabled () {
40 return this.video.isLocal && this.serverConfig.tracker.enabled === false
41 }
42
43 private isP2PDisabled () {
44 return getStoredP2PEnabled() === false
45 }
46
47 private alreadyAccepted () {
48 return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
6ebdd12f
C
49 }
50}