import { Component, ElementRef, ViewChild } from '@angular/core'
-import { Notifier } from '@app/core'
+import { Notifier, UserService } from '@app/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
-import { UserService } from '@app/shared'
+import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
@Component({
selector: 'my-welcome-modal',
export class WelcomeModalComponent {
@ViewChild('modal', { static: true }) modal: ElementRef
+ private LOCAL_STORAGE_KEYS = {
+ NO_WELCOME_MODAL: 'no_welcome_modal'
+ }
+
constructor (
private userService: UserService,
private modalService: NgbModal,
) { }
show () {
- const ref = this.modalService.open(this.modal,{
+ const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL)
+ if (result === 'true') return
+
+ this.modalService.open(this.modal, {
+ centered: true,
backdrop: 'static',
keyboard: false,
size: 'lg'
})
-
- ref.result.finally(() => this.doNotOpenAgain())
}
- private doNotOpenAgain () {
+ doNotOpenAgain () {
+ peertubeLocalStorage.setItem(this.LOCAL_STORAGE_KEYS.NO_WELCOME_MODAL, 'true')
+
this.userService.updateMyProfile({ noWelcomeModal: true })
.subscribe(
() => console.log('We will not open the welcome modal again.'),
err => this.notifier.error(err.message)
)
-
- return true
}
}