Refresh horizontal menu on login change
This commit is contained in:
parent
54bf47122c
commit
3eb1f23977
|
@ -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 = []
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue