1 import { Component, Input, OnInit } from '@angular/core'
2 import { ServerService, User, UserService } from '@app/core'
3 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
4 import { isP2PEnabled } from '@root-helpers/video'
5 import { HTMLServerConfig, Video } from '@shared/models'
8 selector: 'my-privacy-concerns',
9 templateUrl: './privacy-concerns.component.html',
10 styleUrls: [ './privacy-concerns.component.scss' ]
12 export class PrivacyConcernsComponent implements OnInit {
13 private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern'
19 private serverConfig: HTMLServerConfig
22 private serverService: ServerService,
23 private userService: UserService
27 this.serverConfig = this.serverService.getHTMLConfig()
29 this.userService.getAnonymousOrLoggedUser()
30 .subscribe(user => this.updateDisplay(user))
33 acceptedPrivacyConcern () {
34 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
39 private updateDisplay (user: User) {
40 if (isP2PEnabled(this.video, this.serverConfig, user.p2pEnabled) && !this.alreadyAccepted()) {
45 private alreadyAccepted () {
46 return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'