Refresh horizontal menu on login change

This commit is contained in:
Chocobozzz 2024-11-27 10:20:19 +01:00
parent 54bf47122c
commit 3eb1f23977
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 17 additions and 3 deletions

View File

@ -1,6 +1,7 @@
import { Component, OnInit } from '@angular/core'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { AuthService, ServerService } from '@app/core'
import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component'
import { Subscription } from 'rxjs'
@Component({
selector: 'my-home-menu',
@ -8,9 +9,11 @@ import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared
standalone: true,
imports: [ HorizontalMenuComponent ]
})
export class HomeMenuComponent implements OnInit {
export class HomeMenuComponent implements OnInit, OnDestroy {
menuEntries: HorizontalMenuEntry[] = []
private sub: Subscription
constructor (
private server: ServerService,
private authService: AuthService
@ -19,6 +22,17 @@ export class HomeMenuComponent implements OnInit {
}
ngOnInit () {
this.buildMenu()
this.sub = this.authService.loginChangedSource
.subscribe(() => this.buildMenu())
}
ngOnDestroy () {
if (this.sub) this.sub.unsubscribe()
}
buildMenu () {
const config = this.server.getHTMLConfig()
this.menuEntries = []

View File

@ -4,4 +4,4 @@ set -eu
npm run concurrently -- -k \
"cd client/src/standalone/videos/ && npx vite-bundle-visualizer" \
"cd client && npx esbuild-visualizer --metadata ./dist/en-US/stats.json"
"cd client && npx esbuild-visualizer --metadata ./dist/en-US/stats.json --open"