From 5196817c5d7cf86b35f3fa2cfe108ba283944482 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Oct 2021 09:24:22 +0200 Subject: Fix privacy concern for remote videos --- .../information/privacy-concerns.component.html | 2 +- .../information/privacy-concerns.component.ts | 36 ++++++++++++---------- .../+video-watch/video-watch.component.html | 2 +- 3 files changed, 22 insertions(+), 18 deletions(-) (limited to 'client/src/app') diff --git a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html index efad5a2b8..d579aaddb 100644 --- a/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html +++ b/client/src/app/+videos/+video-watch/shared/information/privacy-concerns.component.html @@ -1,4 +1,4 @@ -
+
Friendly Reminder: 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 b1e8bf989..bbc81d46d 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,7 +1,7 @@ -import { Component, OnInit } from '@angular/core' +import { Component, Input, OnInit } from '@angular/core' import { ServerService } from '@app/core' import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' -import { HTMLServerConfig } from '@shared/models' +import { HTMLServerConfig, Video } from '@shared/models' import { getStoredP2PEnabled } from '../../../../../assets/player/peertube-player-local-storage' import { isWebRTCDisabled } from '../../../../../assets/player/utils' @@ -13,7 +13,9 @@ import { isWebRTCDisabled } from '../../../../../assets/player/utils' export class PrivacyConcernsComponent implements OnInit { private static LOCAL_STORAGE_PRIVACY_CONCERN_KEY = 'video-watch-privacy-concern' - hasAlreadyAcceptedPrivacyConcern = false + @Input() video: Video + + display = true private serverConfig: HTMLServerConfig @@ -24,23 +26,25 @@ export class PrivacyConcernsComponent implements OnInit { ngOnInit () { this.serverConfig = this.serverService.getHTMLConfig() - if ( - isWebRTCDisabled() || - this.serverConfig.tracker.enabled === false || - getStoredP2PEnabled() === false || - peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true' - ) { - this.hasAlreadyAcceptedPrivacyConcern = true + if (isWebRTCDisabled() || this.isTrackerDisabled() || this.isP2PDisabled() || this.alreadyAccepted()) { + this.display = false } } - declinedPrivacyConcern () { - peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false') - this.hasAlreadyAcceptedPrivacyConcern = false - } - acceptedPrivacyConcern () { peertubeLocalStorage.setItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') - this.hasAlreadyAcceptedPrivacyConcern = true + this.display = false + } + + private isTrackerDisabled () { + return this.video.isLocal && this.serverConfig.tracker.enabled === false + } + + private isP2PDisabled () { + return getStoredP2PEnabled() === false + } + + private alreadyAccepted () { + return peertubeLocalStorage.getItem(PrivacyConcernsComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true' } } diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html index df74a818b..830215225 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.html +++ b/client/src/app/+videos/+video-watch/video-watch.component.html @@ -106,7 +106,7 @@ >
- +
-- cgit v1.2.3