From 2989628b7913383b39ac34c7db8666a21f8e5037 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 4 Jun 2021 13:31:41 +0200 Subject: Use HTML config when possible --- client/src/app/menu/menu.component.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'client/src/app/menu') diff --git a/client/src/app/menu/menu.component.ts b/client/src/app/menu/menu.component.ts index 2f7e0cf07..c767f19b2 100644 --- a/client/src/app/menu/menu.component.ts +++ b/client/src/app/menu/menu.component.ts @@ -20,7 +20,7 @@ import { LanguageChooserComponent } from '@app/menu/language-chooser.component' import { QuickSettingsModalComponent } from '@app/modal/quick-settings-modal.component' import { PeertubeModalService } from '@app/shared/shared-main/peertube-modal/peertube-modal.service' import { NgbDropdown } from '@ng-bootstrap/ng-bootstrap' -import { ServerConfig, UserRight, VideoConstant } from '@shared/models' +import { HTMLServerConfig, ServerConfig, UserRight, VideoConstant } from '@shared/models' const logger = debug('peertube:menu:MenuComponent') @@ -48,7 +48,10 @@ export class MenuComponent implements OnInit { commonMenuLinks: MenuLink[] = [] private languages: VideoConstant[] = [] + + private htmlServerConfig: HTMLServerConfig private serverConfig: ServerConfig + private routesPerRight: { [role in UserRight]?: string } = { [UserRight.MANAGE_USERS]: '/admin/users', [UserRight.MANAGE_SERVER_FOLLOW]: '/admin/friends', @@ -86,16 +89,12 @@ export class MenuComponent implements OnInit { } get instanceName () { - return this.serverConfig.instance.name + return this.htmlServerConfig.instance.name } ngOnInit () { - this.serverConfig = this.serverService.getTmpConfig() - this.serverService.getConfig() - .subscribe(config => { - this.serverConfig = config - this.buildMenuLinks() - }) + this.htmlServerConfig = this.serverService.getHTMLConfig() + this.buildMenuLinks() this.isLoggedIn = this.authService.isLoggedIn() if (this.isLoggedIn === true) { @@ -148,6 +147,8 @@ export class MenuComponent implements OnInit { } isRegistrationAllowed () { + if (!this.serverConfig) return false + return this.serverConfig.signup.allowed && this.serverConfig.signup.allowedForCurrentIP } @@ -257,7 +258,7 @@ export class MenuComponent implements OnInit { } private buildMenuLinks () { - this.commonMenuLinks = this.menuService.buildCommonLinks(this.serverConfig) + this.commonMenuLinks = this.menuService.buildCommonLinks(this.htmlServerConfig) } private buildUserLanguages () { -- cgit v1.2.3