From 9929fbd6f4e209346cd31d05888417a94949da84 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Apr 2021 15:11:00 +0200 Subject: Fix welcome/warning modal --- .../app/modal/instance-config-warning-modal.component.ts | 14 ++++++++++++++ client/src/app/modal/welcome-modal.component.ts | 10 ++++++++++ 2 files changed, 24 insertions(+) (limited to 'client/src/app/modal') 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..8bf7672be 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,6 +47,8 @@ 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.'), diff --git a/client/src/app/modal/welcome-modal.component.ts b/client/src/app/modal/welcome-modal.component.ts index c2f289600..72ae20b43 100644 --- a/client/src/app/modal/welcome-modal.component.ts +++ b/client/src/app/modal/welcome-modal.component.ts @@ -1,6 +1,7 @@ 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' @Component({ selector: 'my-welcome-modal', @@ -10,6 +11,10 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap' export class WelcomeModalComponent { @ViewChild('modal', { static: true }) modal: ElementRef + private LOCAL_STORAGE_KEYS = { + NO_WELCOME_MODAL: 'no_welcome_modal' + } + constructor ( private userService: UserService, private modalService: NgbModal, @@ -17,6 +22,9 @@ export class WelcomeModalComponent { ) { } show () { + const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) + if (result === 'true') return + this.modalService.open(this.modal, { centered: true, backdrop: 'static', @@ -26,6 +34,8 @@ export class WelcomeModalComponent { } doNotOpenAgain () { + peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true') + this.userService.updateMyProfile({ noWelcomeModal: true }) .subscribe( () => console.log('We will not open the welcome modal again.'), -- cgit v1.2.3