]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
Bumped to version v5.2.1
[github/Chocobozzz/PeerTube.git] / client / src / app / +videos / +video-watch / shared / information / privacy-concerns.component.ts
... / ...
CommitLineData
1import { Component, Input, OnInit } from '@angular/core'
2import { ServerService, User, UserService } from '@app/core'
3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
4import { isP2PEnabled } from '@root-helpers/video'
5import { HTMLServerConfig, Video } from '@shared/models'
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
15 @Input() video: Video
16
17 display = false
18
19 private serverConfig: HTMLServerConfig
20
21 constructor (
22 private serverService: ServerService,
23 private userService: UserService
24 ) { }
25
26 ngOnInit () {
27 this.serverConfig = this.serverService.getHTMLConfig()
28
29 this.userService.getAnonymousOrLoggedUser()
30 .subscribe(user => this.updateDisplay(user))
31 }
32
33 acceptedPrivacyConcern () {
34 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
35
36 this.display = false
37 }
38
39 private updateDisplay (user: User) {
40 if (isP2PEnabled(this.video, this.serverConfig, user.p2pEnabled) && !this.alreadyAccepted()) {
41 this.display = true
42 }
43 }
44
45 private alreadyAccepted () {
46 return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
47 }
48}