1 import { Component, ElementRef, ViewChild } from '@angular/core'
2 import { Notifier, User, UserService } from '@app/core'
3 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4 import { logger } from '@root-helpers/logger'
5 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
8 selector: 'my-admin-welcome-modal',
9 templateUrl: './admin-welcome-modal.component.html',
10 styleUrls: [ './admin-welcome-modal.component.scss' ]
12 export class AdminWelcomeModalComponent {
13 @ViewChild('modal', { static: true }) modal: ElementRef
15 private LOCAL_STORAGE_KEYS = {
16 NO_WELCOME_MODAL: 'no_welcome_modal'
20 private userService: UserService,
21 private modalService: NgbModal,
22 private notifier: Notifier
25 shouldOpen (user: User) {
26 if (user.noWelcomeModal === true) return false
27 if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) === 'true') return false
33 this.modalService.open(this.modal, {
42 peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
44 this.userService.updateMyProfile({ noWelcomeModal: true })
46 next: () => logger.info('We will not open the welcome modal again.'),
48 error: err => this.notifier.error(err.message)