X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fmodal%2Finstance-config-warning-modal.component.ts;h=23c2c777e98b96c19bb23eeab1bded6a0d8160ca;hb=6e060713b428f479d26993f6fd79a062630d2432;hp=5e1433548f767d85f6ad606277938ecf5c4ae16c;hpb=c2777c1dfe688c8fab1ef2fed50e360100fa9198;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/modal/instance-config-warning-modal.component.ts b/client/src/app/modal/instance-config-warning-modal.component.ts index 5e1433548..23c2c777e 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts @@ -1,8 +1,10 @@ +import { Location } from '@angular/common' import { Component, ElementRef, ViewChild } from '@angular/core' -import { Notifier } from '@app/core' +import { Notifier, User, UserService } from '@app/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' -import { About } from '@shared/models/server' -import { UserService } from '@app/shared' +import { logger } from '@root-helpers/logger' +import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' +import { About, ServerConfig } from '@shared/models/server' @Component({ selector: 'my-instance-config-warning-modal', @@ -15,13 +17,36 @@ export class InstanceConfigWarningModalComponent { stopDisplayModal = false about: About + private LOCAL_STORAGE_KEYS = { + NO_INSTANCE_CONFIG_WARNING_MODAL: 'no_instance_config_warning_modal' + } + constructor ( private userService: UserService, + private location: Location, private modalService: NgbModal, private notifier: Notifier ) { } + shouldOpenByUser (user: User) { + if (user.noInstanceConfigWarningModal === true) return false + if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL) === 'true') return false + + return true + } + + shouldOpen (serverConfig: ServerConfig, about: About) { + if (!serverConfig.signup.allowed) return false + + return serverConfig.instance.name.toLowerCase() === 'peertube' || + !about.instance.terms || + !about.instance.administrator || + !about.instance.maintenanceLifetime + } + show (about: About) { + if (this.location.path().startsWith('/admin/config/edit-custom')) return + this.about = about const ref = this.modalService.open(this.modal, { centered: true }) @@ -32,16 +57,17 @@ export class InstanceConfigWarningModalComponent { } isDefaultShortDescription (description: string) { - return description === 'PeerTube, a federated (ActivityPub) video streaming platform using P2P (BitTorrent) directly ' + - 'in the web browser with WebTorrent and Angular.' + return description === 'PeerTube, an ActivityPub-federated video streaming platform using P2P directly in your web browser.' } private doNotOpenAgain () { + peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL, 'true') + this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) - .subscribe( - () => console.log('We will not open the instance config warning modal again.'), + .subscribe({ + next: () => logger.info('We will not open the instance config warning modal again.'), - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } }