<div class="peertube-select-container">
<select formControlName="default" id="themeDefault" class="form-control">
- <option i18n value="default">default</option>
+ <option i18n value="default">{{ getDefaultThemeLabel() }}</option>
<option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option>
</select>
import { SelectOptionsItem } from 'src/types/select-options-item.model'
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'
import { FormGroup } from '@angular/forms'
-import { MenuService } from '@app/core'
+import { MenuService, ThemeService } from '@app/core'
import { HTMLServerConfig } from '@shared/models'
import { ConfigService } from '../shared/config.service'
constructor (
private configService: ConfigService,
- private menuService: MenuService
+ private menuService: MenuService,
+ private themeService: ThemeService
) { }
ngOnInit () {
}
getAvailableThemes () {
- return this.serverConfig.theme.registered
- .map(t => t.name)
+ return this.themeService.getAvailableThemeLabels()
}
doesTrendingVideosAlgorithmsEnabledInclude (algorithm: string) {
}))
}
+ getDefaultThemeLabel () {
+ return this.themeService.getDefaultThemeLabel()
+ }
+
private checkSignupField () {
const signupControl = this.form.get('signup.enabled')
import { Injectable } from '@angular/core'
+import { capitalizeFirstLetter } from '@root-helpers/string'
import { UserLocalStorageKeys } from '@root-helpers/users'
import { HTMLServerConfig, ServerConfigTheme } from '@shared/models'
import { environment } from '../../../environments/environment'
this.listenUserTheme()
}
+ getDefaultThemeLabel () {
+ if (this.hasDarkTheme()) {
+ return $localize`Light/Orange or Dark`
+ }
+
+ return $localize`Light/Orange`
+ }
+
+ getAvailableThemeLabels () {
+ return this.serverConfig.theme.registered
+ .map(t => capitalizeFirstLetter(t.name))
+ }
+
private injectThemes (themes: ServerConfigTheme[], fromLocalStorage = false) {
this.themes = themes
if (instanceTheme !== 'default') return instanceTheme
// Default to dark theme if available and wanted by the user
- if (
- this.themes.find(t => t.name === 'dark') &&
- window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
- ) {
+ if (this.hasDarkTheme() && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return 'dark'
}
private getTheme (name: string) {
return this.themes.find(t => t.name === name)
}
+
+ private hasDarkTheme () {
+ return this.serverConfig.theme.registered.some(t => t.name === 'dark')
+ }
}
<div class="peertube-select-container">
<select formControlName="theme" id="theme" class="form-control">
- <option i18n value="instance-default">Instance default theme ({{ getDefaultThemeLabel() }})</option>
- <option i18n value="default">{{ defaultThemeLabel }}</option>
+ <option i18n value="instance-default">{{ instanceName }} default theme ({{ getDefaultInstanceThemeLabel() }})</option>
+ <option i18n value="default">{{ getDefaultThemeLabel() }}</option>
- <option *ngFor="let theme of availableThemes" [value]="theme">{{ capitalizeFirstLetter(theme) }}</option>
+ <option *ngFor="let theme of getAvailableThemes()" [value]="theme">{{ theme }}</option>
</select>
</div>
</div>
import { Subject, Subscription } from 'rxjs'
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
-import { AuthService, Notifier, ServerService, UserService } from '@app/core'
+import { AuthService, Notifier, ServerService, ThemeService, UserService } from '@app/core'
import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
-import { capitalizeFirstLetter } from '@root-helpers/string'
import { HTMLServerConfig, User, UserUpdateMe } from '@shared/models'
@Component({
formValuesWatcher: Subscription
- defaultThemeLabel = $localize`Light/Orange`
-
private serverConfig: HTMLServerConfig
constructor (
private authService: AuthService,
private notifier: Notifier,
private userService: UserService,
+ private themeService: ThemeService,
private serverService: ServerService
) {
super()
}
- get availableThemes () {
- return this.serverConfig.theme.registered
- .map(t => t.name)
+ get instanceName () {
+ return this.serverConfig.instance.name
}
ngOnInit () {
}
getDefaultThemeLabel () {
+ return this.themeService.getDefaultThemeLabel()
+ }
+
+ getAvailableThemes () {
+ return this.themeService.getAvailableThemeLabels()
+ }
+
+ getDefaultInstanceThemeLabel () {
const theme = this.serverConfig.theme.default
- if (theme === 'default') return this.defaultThemeLabel
+ if (theme === 'default') {
+ return this.getDefaultThemeLabel()
+ }
return theme
}
- capitalizeFirstLetter (str: string) {
- return capitalizeFirstLetter(str)
- }
-
updateInterfaceSettings () {
const theme = this.form.value['theme']