aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/admin-welcome-modal.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-27 10:15:55 +0200
committerChocobozzz <me@florianbigard.com>2021-08-27 10:15:55 +0200
commit8f581725651c4b2c213d75fc028e306bbf239d3e (patch)
tree8deb842327c2a227d8e302d9a84bd9f8f9f7affa /client/src/app/modal/admin-welcome-modal.component.ts
parent1ff15061b31245df4248e47228d0a90b07ab3f01 (diff)
downloadPeerTube-8f581725651c4b2c213d75fc028e306bbf239d3e.tar.gz
PeerTube-8f581725651c4b2c213d75fc028e306bbf239d3e.tar.zst
PeerTube-8f581725651c4b2c213d75fc028e306bbf239d3e.zip
Allow accounts to skip account setup modal
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}