1 import { Component, ElementRef, ViewChild } from '@angular/core'
2 import { Notifier, UserService } from '@app/core'
3 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
7 selector: 'my-welcome-modal',
8 templateUrl: './welcome-modal.component.html',
9 styleUrls: [ './welcome-modal.component.scss' ]
11 export class WelcomeModalComponent {
12 @ViewChild('modal', { static: true }) modal: ElementRef
14 private LOCAL_STORAGE_KEYS = {
15 NO_WELCOME_MODAL: 'no_welcome_modal'
19 private userService: UserService,
20 private modalService: NgbModal,
21 private notifier: Notifier
25 const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL)
26 if (result === 'true') return
28 this.modalService.open(this.modal, {
37 peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
39 this.userService.updateMyProfile({ noWelcomeModal: true })
41 () => console.log('We will not open the welcome modal again.'),
43 err => this.notifier.error(err.message)