]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/modal/welcome-modal.component.ts
Translated using Weblate (Kabyle)
[github/Chocobozzz/PeerTube.git] / client / src / app / modal / welcome-modal.component.ts
index 05412a4cdb2060590704b4cbb8230869d24de690..72ae20b43eb86148875b65ef1e5eb81b1a93c4f3 100644 (file)
@@ -1,7 +1,7 @@
 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',
@@ -11,6 +11,10 @@ import { UserService } from '@app/shared'
 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,
@@ -18,16 +22,20 @@ export class WelcomeModalComponent {
   ) { }
 
   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.'),