]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
Move privacy concerns in a dedicated component
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / shared / information / privacy-concerns.component.ts
CommitLineData
6ebdd12f
C
1import { Component, OnInit } from '@angular/core'
2import { ServerService } from '@app/core'
3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
4import { HTMLServerConfig } from '@shared/models'
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
16 hasAlreadyAcceptedPrivacyConcern = false
17
18 private serverConfig: HTMLServerConfig
19
20 constructor (
21 private serverService: ServerService
22 ) { }
23
24 async ngOnInit () {
25 this.serverConfig = this.serverService.getHTMLConfig()
26 if (
27 isWebRTCDisabled() ||
28 this.serverConfig.tracker.enabled === false ||
29 getStoredP2PEnabled() === false ||
30 peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
31 ) {
32 this.hasAlreadyAcceptedPrivacyConcern = true
33 }
34 }
35
36 declinedPrivacyConcern () {
37 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false')
38 this.hasAlreadyAcceptedPrivacyConcern = false
39 }
40
41 acceptedPrivacyConcern () {
42 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
43 this.hasAlreadyAcceptedPrivacyConcern = true
44 }
45}