aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/account-setup-modal.component.ts
diff options
context:
space:
mode:
authorMs Kimsible <1877318+kimsible@users.noreply.github.com>2021-08-26 08:22:33 +0200
committerGitHub <noreply@github.com>2021-08-26 08:22:33 +0200
commit7dca45f99db58d9bb3423a3765aaee68c69bc9f2 (patch)
tree6bdf45c304a58dca51a8e856a8d35238e7bc9bbb /client/src/app/modal/account-setup-modal.component.ts
parent8729a87024fc837f7dd6f13afeec90cf6dda1c06 (diff)
downloadPeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.tar.gz
PeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.tar.zst
PeerTube-7dca45f99db58d9bb3423a3765aaee68c69bc9f2.zip
Inform user to fill account profile and channels (#4352)
* Add account-setup modal when login * Add channels-setup alert into my-channels, my-playlists and upload page Co-authored-by: Ms Kimsible <kimsible@users.noreply.github.com>
Diffstat (limited to 'client/src/app/modal/account-setup-modal.component.ts')
-rw-r--r--client/src/app/modal/account-setup-modal.component.ts70
1 files changed, 70 insertions, 0 deletions
diff --git a/client/src/app/modal/account-setup-modal.component.ts b/client/src/app/modal/account-setup-modal.component.ts
new file mode 100644
index 000000000..e5d36e006
--- /dev/null
+++ b/client/src/app/modal/account-setup-modal.component.ts
@@ -0,0 +1,70 @@
1import { Component, ElementRef, OnInit, ViewChild } from '@angular/core'
2import { AuthService, ServerService, User } from '@app/core'
3import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
4import { HTMLServerConfig } from '@shared/models'
5
6@Component({
7 selector: 'my-account-setup-modal',
8 templateUrl: './account-setup-modal.component.html',
9 styleUrls: [ './account-setup-modal.component.scss' ]
10})
11export class AccountSetupModalComponent implements OnInit {
12 @ViewChild('modal', { static: true }) modal: ElementRef
13
14 user: User = null
15 ref: NgbModalRef = null
16
17 private serverConfig: HTMLServerConfig
18
19 constructor (
20 private authService: AuthService,
21 private modalService: NgbModal,
22 private serverService: ServerService
23 ) { }
24
25 get userInformationLoaded () {
26 return this.authService.userInformationLoaded
27 }
28
29 get instanceName () {
30 return this.serverConfig.instance.name
31 }
32
33 get isUserRoot () {
34 return this.user.username === 'root'
35 }
36
37 get hasAccountAvatar () {
38 return !!this.user.account.avatar
39 }
40
41 get hasAccountDescription () {
42 return !!this.user.account.description
43 }
44
45 ngOnInit () {
46 this.serverConfig = this.serverService.getHTMLConfig()
47 this.user = this.authService.getUser()
48
49 this.authService.userInformationLoaded
50 .subscribe(
51 () => {
52 if (this.isUserRoot) return false
53 if (this.hasAccountAvatar && this.hasAccountDescription) return false
54
55 this.show()
56 }
57 )
58 }
59
60 show () {
61 if (this.ref) return false
62
63 this.ref = this.modalService.open(this.modal, {
64 centered: true,
65 backdrop: 'static',
66 keyboard: false,
67 size: 'md'
68 })
69 }
70}