]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/modal/welcome-modal.component.ts
Move to sass module
[github/Chocobozzz/PeerTube.git] / client / src / app / modal / welcome-modal.component.ts
CommitLineData
43d0ea7f 1import { Component, ElementRef, ViewChild } from '@angular/core'
67ed6552 2import { Notifier, UserService } from '@app/core'
43d0ea7f 3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
9929fbd6 4import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
43d0ea7f
C
5
6@Component({
7 selector: 'my-welcome-modal',
8 templateUrl: './welcome-modal.component.html',
9 styleUrls: [ './welcome-modal.component.scss' ]
10})
11export class WelcomeModalComponent {
12 @ViewChild('modal', { static: true }) modal: ElementRef
13
9929fbd6
C
14 private LOCAL_STORAGE_KEYS = {
15 NO_WELCOME_MODAL: 'no_welcome_modal'
16 }
17
43d0ea7f
C
18 constructor (
19 private userService: UserService,
20 private modalService: NgbModal,
21 private notifier: Notifier
22 ) { }
23
24 show () {
9929fbd6
C
25 const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL)
26 if (result === 'true') return
27
24e7916c
RK
28 this.modalService.open(this.modal, {
29 centered: true,
43d0ea7f
C
30 backdrop: 'static',
31 keyboard: false,
32 size: 'lg'
33 })
43d0ea7f
C
34 }
35
4618b686 36 doNotOpenAgain () {
9929fbd6
C
37 peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
38
43d0ea7f
C
39 this.userService.updateMyProfile({ noWelcomeModal: true })
40 .subscribe(
41 () => console.log('We will not open the welcome modal again.'),
42
43 err => this.notifier.error(err.message)
44 )
43d0ea7f
C
45 }
46}