Fix welcome/warning modal

pull/4000/head
Chocobozzz 2021-04-20 15:11:00 +02:00
parent 4024c44f90
commit 9929fbd6f4
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 24 additions and 0 deletions

View File

@ -1,6 +1,8 @@
import { Location } from '@angular/common'
import { Component, ElementRef, ViewChild } from '@angular/core' import { Component, ElementRef, ViewChild } from '@angular/core'
import { Notifier, UserService } from '@app/core' import { Notifier, UserService } from '@app/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
import { About } from '@shared/models/server' import { About } from '@shared/models/server'
@Component({ @Component({
@ -14,13 +16,23 @@ export class InstanceConfigWarningModalComponent {
stopDisplayModal = false stopDisplayModal = false
about: About about: About
private LOCAL_STORAGE_KEYS = {
NO_INSTANCE_CONFIG_WARNING_MODAL: 'no_instance_config_warning_modal'
}
constructor ( constructor (
private userService: UserService, private userService: UserService,
private location: Location,
private modalService: NgbModal, private modalService: NgbModal,
private notifier: Notifier private notifier: Notifier
) { } ) { }
show (about: About) { 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 this.about = about
const ref = this.modalService.open(this.modal, { centered: true }) const ref = this.modalService.open(this.modal, { centered: true })
@ -35,6 +47,8 @@ export class InstanceConfigWarningModalComponent {
} }
private doNotOpenAgain () { private doNotOpenAgain () {
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL, 'true')
this.userService.updateMyProfile({ noInstanceConfigWarningModal: true }) this.userService.updateMyProfile({ noInstanceConfigWarningModal: true })
.subscribe( .subscribe(
() => console.log('We will not open the instance config warning modal again.'), () => console.log('We will not open the instance config warning modal again.'),

View File

@ -1,6 +1,7 @@
import { Component, ElementRef, ViewChild } from '@angular/core' import { Component, ElementRef, ViewChild } from '@angular/core'
import { Notifier, UserService } from '@app/core' import { Notifier, UserService } from '@app/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
@Component({ @Component({
selector: 'my-welcome-modal', selector: 'my-welcome-modal',
@ -10,6 +11,10 @@ import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
export class WelcomeModalComponent { export class WelcomeModalComponent {
@ViewChild('modal', { static: true }) modal: ElementRef @ViewChild('modal', { static: true }) modal: ElementRef
private LOCAL_STORAGE_KEYS = {
NO_WELCOME_MODAL: 'no_welcome_modal'
}
constructor ( constructor (
private userService: UserService, private userService: UserService,
private modalService: NgbModal, private modalService: NgbModal,
@ -17,6 +22,9 @@ export class WelcomeModalComponent {
) { } ) { }
show () { show () {
const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL)
if (result === 'true') return
this.modalService.open(this.modal, { this.modalService.open(this.modal, {
centered: true, centered: true,
backdrop: 'static', backdrop: 'static',
@ -26,6 +34,8 @@ export class WelcomeModalComponent {
} }
doNotOpenAgain () { doNotOpenAgain () {
peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
this.userService.updateMyProfile({ noWelcomeModal: true }) this.userService.updateMyProfile({ noWelcomeModal: true })
.subscribe( .subscribe(
() => console.log('We will not open the welcome modal again.'), () => console.log('We will not open the welcome modal again.'),