ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix color customizations with dark theme
Chocobozzz9fc748b11fa6
diff --git a/client/src/app/+admin/config/pages/admin-config-customization.component.ts b/client/src/app/+admin/config/pages/admin-config-customization.component.tsindex db27b6cb8e..291389eab9 100644--- a/client/src/app/+admin/config/pages/admin-config-customization.component.ts+++ b/client/src/app/+admin/config/pages/admin-config-customization.component.ts@@ -196,7 +196,7 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, CanngOnDestroy () {if (this.customConfigSub) this.customConfigSub.unsubscribe()- this.themeService.updateColorPalette(this.customConfig.theme)+ this.themeService.updateColorPalette({ builtIn: this.serverService.getHTMLConfig().theme.builtIn, ...this.customConfig.theme })}canDeactivate () {@@ -216,6 +216,8 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Canthis.themeService.updateColorPalette({...this.customConfig.theme,+ builtIn: this.serverService.getHTMLConfig().theme.builtIn,+customization: this.buildNewCustomization(formValues)})})@@ -321,6 +323,13 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Canreturn this.availableThemes.find(t => t.id === this.getDefaultThemeName())?.label}+ isUsingDefaultTheme () {+ this.themeService.isUsingDefaultTheme({+ currentTheme: this.getCurrentThemeName(),+ config: this.serverService.getHTMLConfig().theme+ })+ }+hasDefaultCustomizationValue (field: ThemeCustomizationKey) {return this.customizationResetFields.has(field)}@@ -331,6 +340,8 @@ export class AdminConfigCustomizationComponent implements OnInit, OnDestroy, Canthis.themeService.updateColorPalette({...this.customConfig.theme,+ builtIn: this.serverService.getHTMLConfig().theme.builtIn,+customization: this.buildNewCustomization(this.form.get('theme.customization').value)})diff --git a/client/src/app/core/theme/theme.service.ts b/client/src/app/core/theme/theme.service.tsindex fd1e58bd8c..52a3144cf7 100644--- a/client/src/app/core/theme/theme.service.ts+++ b/client/src/app/core/theme/theme.service.ts@@ -118,6 +118,13 @@ export class ThemeService {return instanceTheme}+ isUsingDefaultTheme (options: {+ currentTheme: string+ config: Pick<ColorPaletteThemeConfig, 'default' | 'builtIn'>+ }) {+ return this.themeManager.isUsingDefaultTheme(options)+ }+private updateCurrentTheme () {const currentThemeName = this.getCurrentThemeName()if (this.oldThemeName === currentThemeName) returndiff --git a/client/src/root-helpers/theme-manager.ts b/client/src/root-helpers/theme-manager.tsindex 69ca0dea48..a740287037 100644--- a/client/src/root-helpers/theme-manager.ts+++ b/client/src/root-helpers/theme-manager.ts@@ -9,7 +9,7 @@ const debugLogger = debug('peertube:theme')type ConfigCSSVariableMap = Record<keyof ServerConfig['theme']['customization'], string>export type ThemeCustomizationKey = keyof ConfigCSSVariableMap-export type ColorPaletteThemeConfig = Pick<HTMLServerConfig['theme'], 'default' | 'customization'>+export type ColorPaletteThemeConfig = Pick<HTMLServerConfig['theme'], 'default' | 'customization' | 'builtIn'>export class ThemeManager {private configVariablesStyle: HTMLStyleElement@@ -54,8 +54,8 @@ export class ThemeManager {this.configuredCSSVariables.clear()this.configVariablesStyle.textContent = ''- // Only inject config variables for the default theme- if (currentTheme !== config.default) return+ // Only inject config variables for the default theme, otherwise we may override the theme colors with wrong values+ if (!this.isUsingDefaultTheme({ currentTheme, config })) returnconst computedStyle = getComputedStyle(document.documentElement)@@ -148,6 +148,23 @@ export class ThemeManager {this.getHeadElement().removeChild(linkEl)}+ isUsingDefaultTheme (options: {+ currentTheme: string+ config: Pick<ColorPaletteThemeConfig, 'default' | 'builtIn'>+ }) {+ const { currentTheme, config } = options++ if (currentTheme === config.default) return true++ // Only inject config variables for the default theme+ if (config.default === 'default') {+ // Accept built-in themes+ return config.builtIn.some(t => t.name === currentTheme)+ }++ return false+ }+private canInjectCoreColorPalette () {const computedStyle = getComputedStyle(document.documentElement)const isDark = computedStyle.getPropertyValue('--is-dark')