]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/menu/menu.component.ts
Various front optimizations
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / menu.component.ts
index 97a3b6d24ea3081781a9f880c4b1c082d79b4035..bdc95127b4a91d57ba55a08c4d5abfdc51505530 100644 (file)
@@ -28,6 +28,11 @@ export class MenuComponent implements OnInit {
   helpVisible = false
 
   videoLanguages: string[] = []
+  nsfwPolicy: string
+
+  loggedInMorePlacement: string
+
+  currentInterfaceLanguage: string
 
   private languages: VideoConstant<string>[] = []
   private serverConfig: ServerConfig
@@ -52,37 +57,6 @@ export class MenuComponent implements OnInit {
     private router: Router
   ) { }
 
-  get isInMobileView () {
-    return this.screenService.isInMobileView()
-  }
-
-  get placement () {
-    if (this.isInMobileView) {
-      return 'left-top auto'
-    } else {
-      return 'right-top auto'
-    }
-  }
-
-  get language () {
-    return this.languageChooserModal.getCurrentLanguage()
-  }
-
-  get nsfwPolicy () {
-    if (!this.user) return
-
-    switch (this.user.nsfwPolicy) {
-      case 'do_not_list':
-        return $localize`hide`
-
-      case 'blur':
-        return $localize`blur`
-
-      case 'display':
-        return $localize`display`
-    }
-  }
-
   get instanceName () {
     return this.serverConfig.instance.name
   }
@@ -95,11 +69,19 @@ export class MenuComponent implements OnInit {
     this.isLoggedIn = this.authService.isLoggedIn()
     if (this.isLoggedIn === true) {
       this.user = this.authService.getUser()
+
+      this.computeNSFWPolicy()
       this.computeVideosLink()
     }
 
     this.computeAdminAccess()
 
+    this.loggedInMorePlacement = this.screenService.isInMobileView()
+      ? 'left-top auto'
+      : 'right-top auto'
+
+    this.currentInterfaceLanguage = this.languageChooserModal.getCurrentLanguage()
+
     this.authService.loginChangedSource.subscribe(
       status => {
         if (status === AuthStatus.LoggedIn) {
@@ -252,4 +234,25 @@ export class MenuComponent implements OnInit {
         else logger('User cannot see videos link.')
       })
   }
+
+  private computeNSFWPolicy () {
+    if (!this.user) {
+      this.nsfwPolicy = null
+      return
+    }
+
+    switch (this.user.nsfwPolicy) {
+      case 'do_not_list':
+        this.nsfwPolicy = $localize`hide`
+        break
+
+      case 'blur':
+        this.nsfwPolicy = $localize`blur`
+        break
+
+      case 'display':
+        this.nsfwPolicy = $localize`display`
+        break
+    }
+  }
 }