Fix setting theme in client

pull/5098/head
Chocobozzz 2022-06-27 09:59:10 +02:00
parent b713976afb
commit 00fe5d6136
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 11 additions and 12 deletions

View File

@ -17,7 +17,7 @@
<select formControlName="default" id="themeDefault" class="form-control">
<option i18n value="default">{{ getDefaultThemeLabel() }}</option>
<option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option>
<option *ngFor="let theme of availableThemes" [value]="theme.id">{{ theme.label }}</option>
</select>
</div>
</div>

View File

@ -19,6 +19,7 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
signupAlertMessage: string
defaultLandingPageOptions: SelectOptionsItem[] = []
availableThemes: SelectOptionsItem[]
constructor (
private configService: ConfigService,
@ -29,6 +30,8 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
ngOnInit () {
this.buildLandingPageOptions()
this.checkSignupField()
this.availableThemes = this.themeService.buildAvailableThemes()
}
ngOnChanges (changes: SimpleChanges) {
@ -49,10 +52,6 @@ export class EditBasicConfigurationComponent implements OnInit, OnChanges {
return this.configService.videoQuotaDailyOptions
}
getAvailableThemes () {
return this.themeService.getAvailableThemeLabels()
}
doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) {
const enabled = this.form.value['trending']['videos']['algorithms']['enabled']
if (!Array.isArray(enabled)) return false

View File

@ -49,9 +49,9 @@ export class ThemeService {
return $localize`Light/Orange`
}
getAvailableThemeLabels () {
buildAvailableThemes () {
return this.serverConfig.theme.registered
.map(t => capitalizeFirstLetter(t.name))
.map(t => ({ id: t.name, label: capitalizeFirstLetter(t.name) }))
}
private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) {

View File

@ -8,7 +8,7 @@
<option i18n value="instance-default">{{ instanceName }} default theme ({{ getDefaultInstanceThemeLabel() }})</option>
<option i18n value="default">{{ getDefaultThemeLabel() }}</option>
<option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option>
<option *ngFor="let theme of availableThemes" [value]="theme.id">{{ theme.label }}</option>
</select>
</div>
</div>

View File

@ -3,6 +3,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
import { SelectOptionsItem } from 'src/types'
@Component({
selector: 'my-user-interface-settings',
@ -15,6 +16,7 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
@Input() notifyOnUpdate = true
@Input() userInformationLoaded: Subject<any>
availableThemes: SelectOptionsItem[]
formValuesWatcher: Subscription
private serverConfig: HTMLServerConfig
@ -37,6 +39,8 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
ngOnInit () {
this.serverConfig = this.serverService.getHTMLConfig()
this.availableThemes = this.themeService.buildAvailableThemes()
this.buildForm({
theme: null
})
@ -61,10 +65,6 @@ export class UserInterfaceSettingsComponent extends FormReactive implements OnIn
return this.themeService.getDefaultThemeLabel()
}
getAvailableThemes () {
return this.themeService.getAvailableThemeLabels()
}
getDefaultInstanceThemeLabel () {
const theme = this.serverConfig.theme.default