X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fmodal%2Finstance-config-warning-modal.component.ts;h=e4095897661805db231947fb66e4ffcdfe7a6f72;hb=bf80903fde923e0c84226ac442a2a382db74aee4;hp=c42413fc057c59f9cabac650a09f81bdc717e1ed;hpb=51de2c7ff3304a553d4e422c2eef23910edf5b55;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 c42413fc0..e40958976 100644 --- a/client/src/app/modal/instance-config-warning-modal.component.ts +++ b/client/src/app/modal/instance-config-warning-modal.component.ts @@ -1,6 +1,8 @@ +import { Location } from '@angular/common' import { Component, ElementRef, ViewChild } from '@angular/core' import { Notifier, UserService } from '@app/core' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' +import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' import { About } from '@shared/models/server' @Component({ @@ -14,13 +16,23 @@ 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 ) { } show (about: About) { + const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL) + if (result === 'true') return + + if (this.location.path().startsWith('/admin/config/edit-custom')) return + this.about = about const ref = this.modalService.open(this.modal, { centered: true }) @@ -35,11 +47,13 @@ export class InstanceConfigWarningModalComponent { } 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: () => console.log('We will not open the instance config warning modal again.'), - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } }