aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/admin-welcome-modal.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/modal/admin-welcome-modal.component.ts')
-rw-r--r--client/src/app/modal/admin-welcome-modal.component.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/src/app/modal/admin-welcome-modal.component.ts b/client/src/app/modal/admin-welcome-modal.component.ts
new file mode 100644
index 000000000..3679f0847
--- /dev/null
+++ b/client/src/app/modal/admin-welcome-modal.component.ts
@@ -0,0 +1,50 @@
1import { Component, ElementRef, ViewChild } from '@angular/core'
2import { Notifier, User, UserService } from '@app/core'
3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
5
6@Component({
7 selector: 'my-admin-welcome-modal',
8 templateUrl: './admin-welcome-modal.component.html',
9 styleUrls: [ './admin-welcome-modal.component.scss' ]
10})
11export class AdminWelcomeModalComponent {
12 @ViewChild('modal', { static: true }) modal: ElementRef
13
14 private LOCAL_STORAGE_KEYS = {
15 NO_WELCOME_MODAL: 'no_welcome_modal'
16 }
17
18 constructor (
19 private userService: UserService,
20 private modalService: NgbModal,
21 private notifier: Notifier
22 ) { }
23
24 shouldOpen (user: User) {
25 if (user.noWelcomeModal === true) return false
26 if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL) === 'true') return false
27
28 return true
29 }
30
31 show () {
32 this.modalService.open(this.modal, {
33 centered: true,
34 backdrop: 'static',
35 keyboard: false,
36 size: 'lg'
37 })
38 }
39
40 doNotOpenAgain () {
41 peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
42
43 this.userService.updateMyProfile({ noWelcomeModal: true })
44 .subscribe({
45 next: () => console.log('We will not open the welcome modal again.'),
46
47 error: err => this.notifier.error(err.message)
48 })
49 }
50}