]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/app.component.ts
Update build steps for localization
[github/Chocobozzz/PeerTube.git] / client / src / app / app.component.ts
index a62aa487092e04bccf4fcf1dc317a43a88209437..ee95d2cbb47c589eb2d43c14f56bcec6a666d932 100644 (file)
@@ -13,9 +13,11 @@ import { InstanceConfigWarningModalComponent } from '@app/modal/instance-config-
 import { WelcomeModalComponent } from '@app/modal/welcome-modal.component'
 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
 import { I18n } from '@ngx-translate/i18n-polyfill'
-import { BroadcastMessageLevel, getShortLocale, is18nPath, ServerConfig, UserRole } from '@shared/models'
+import { getShortLocale, is18nPath } from '@shared/core-utils/i18n'
+import { BroadcastMessageLevel, ServerConfig, UserRole } from '@shared/models'
 import { MenuService } from './core/menu/menu.service'
-import { peertubeLocalStorage, POP_STATE_MODAL_DISMISS } from './helpers'
+import { POP_STATE_MODAL_DISMISS } from './helpers'
+import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage'
 import { InstanceService } from './shared/shared-instance'
 
 @Component({
@@ -108,6 +110,7 @@ export class AppComponent implements OnInit, AfterViewInit {
     peertubeLocalStorage.setItem(AppComponent.BROADCAST_MESSAGE_KEY, this.serverConfig.broadcastMessage.message)
 
     this.broadcastMessage = null
+    this.screenService.isBroadcastMessageDisplayed = false
   }
 
   private initRouteEvents () {
@@ -117,12 +120,17 @@ export class AppComponent implements OnInit, AfterViewInit {
     const scrollEvent = eventsObs.pipe(filter((e: Event): e is Scroll => e instanceof Scroll))
 
     scrollEvent.subscribe(e => {
-      if (e.position) {
-        return this.viewportScroller.scrollToPosition(e.position)
+      // scrollToAnchor first to preserve anchor position when using history navigation
+      if (e.anchor) {
+        setTimeout(() => {
+          this.viewportScroller.scrollToAnchor(e.anchor)
+        })
+
+        return
       }
 
-      if (e.anchor) {
-        return this.viewportScroller.scrollToAnchor(e.anchor)
+      if (e.position) {
+        return this.viewportScroller.scrollToPosition(e.position)
       }
 
       if (resetScroll) {
@@ -184,6 +192,7 @@ export class AppComponent implements OnInit, AfterViewInit {
       this.serverService.configReloaded
     ).subscribe(async config => {
       this.broadcastMessage = null
+      this.screenService.isBroadcastMessageDisplayed = false
 
       const messageConfig = config.broadcastMessage
 
@@ -204,6 +213,8 @@ export class AppComponent implements OnInit, AfterViewInit {
           dismissable: messageConfig.dismissable,
           class: classes[messageConfig.level]
         }
+
+        this.screenService.isBroadcastMessageDisplayed = true
       }
     })
   }