]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/modal/instance-config-warning-modal.component.ts
Translated using Weblate (German)
[github/Chocobozzz/PeerTube.git] / client / src / app / modal / instance-config-warning-modal.component.ts
index e4095897661805db231947fb66e4ffcdfe7a6f72..23c2c777e98b96c19bb23eeab1bded6a0d8160ca 100644 (file)
@@ -1,9 +1,10 @@
 import { Location } from '@angular/common'
 import { Component, ElementRef, ViewChild } from '@angular/core'
-import { Notifier, UserService } from '@app/core'
+import { Notifier, User, UserService } from '@app/core'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { logger } from '@root-helpers/logger'
 import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
-import { About } from '@shared/models/server'
+import { About, ServerConfig } from '@shared/models/server'
 
 @Component({
   selector: 'my-instance-config-warning-modal',
@@ -27,10 +28,23 @@ export class InstanceConfigWarningModalComponent {
     private notifier: Notifier
   ) { }
 
-  show (about: About) {
-    const result = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL)
-    if (result === 'true') return
+  shouldOpenByUser (user: User) {
+    if (user.noInstanceConfigWarningModal === true) return false
+    if (peertubeLocalStorage.getItem(this.LOCAL_STORAGE_KEYS.NO_INSTANCE_CONFIG_WARNING_MODAL) === 'true') return false
+
+    return true
+  }
+
+  shouldOpen (serverConfig: ServerConfig, about: About) {
+    if (!serverConfig.signup.allowed) return false
 
+    return serverConfig.instance.name.toLowerCase() === 'peertube' ||
+      !about.instance.terms ||
+      !about.instance.administrator ||
+      !about.instance.maintenanceLifetime
+  }
+
+  show (about: About) {
     if (this.location.path().startsWith('/admin/config/edit-custom')) return
 
     this.about = about
@@ -51,7 +65,7 @@ export class InstanceConfigWarningModalComponent {
 
     this.userService.updateMyProfile({ noInstanceConfigWarningModal: true })
         .subscribe({
-          next: () => console.log('We will not open the instance config warning modal again.'),
+          next: () => logger.info('We will not open the instance config warning modal again.'),
 
           error: err => this.notifier.error(err.message)
         })