aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts')
-rw-r--r--client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts26
1 files changed, 12 insertions, 14 deletions
diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
index bbc81d46d..24030df3e 100644
--- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.ts
@@ -1,9 +1,8 @@
1import { Component, Input, OnInit } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService, User, UserService } from '@app/core'
3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' 3import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
4import { HTMLServerConfig, Video } from '@shared/models' 4import { HTMLServerConfig, Video } from '@shared/models'
5import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage' 5import { isP2PEnabled } from '../../../../../assets/player/utils'
6import { isWebRTCDisabled } from '../../../../../assets/player/utils'
7 6
8@Component({ 7@Component({
9 selector: 'my-privacy-concerns', 8 selector: 'my-privacy-concerns',
@@ -15,33 +14,32 @@ export class PrivacyConcernsComponent implements OnInit {
15 14
16 @Input() video: Video 15 @Input() video: Video
17 16
18 display = true 17 display = false
19 18
20 private serverConfig: HTMLServerConfig 19 private serverConfig: HTMLServerConfig
21 20
22 constructor ( 21 constructor (
23 private serverService: ServerService 22 private serverService: ServerService,
23 private userService: UserService
24 ) { } 24 ) { }
25 25
26 ngOnInit () { 26 ngOnInit () {
27 this.serverConfig = this.serverService.getHTMLConfig() 27 this.serverConfig = this.serverService.getHTMLConfig()
28 28
29 if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) { 29 this.userService.getAnonymousOrLoggedUser()
30 this.display = false 30 .subscribe(user => this.updateDisplay(user))
31 }
32 } 31 }
33 32
34 acceptedPrivacyConcern () { 33 acceptedPrivacyConcern () {
35 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') 34 peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true')
36 this.display = false
37 }
38 35
39 private isTrackerDisabled () { 36 this.display = false
40 return this.video.isLocal && this.serverConfig.tracker.enabled === false
41 } 37 }
42 38
43 private isP2PDisabled () { 39 private updateDisplay (user: User) {
44 return getStoredP2PEnabled() === false 40 if (isP2PEnabled(this.video, this.serverConfig, user.p2pEnabled) && !this.alreadyAccepted()) {
41 this.display = true
42 }
45 } 43 }
46 44
47 private alreadyAccepted () { 45 private alreadyAccepted () {