Skip to content

Commit 9949849

Browse files
committed
Fix default primary for user theming
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
1 parent 9c79197 commit 9949849

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

apps/theming/lib/ThemingDefaults.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ public function getColorPrimary(): string {
231231
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', '');
232232
// If the user selected the default background
233233
if ($themingBackground === '') {
234-
return BackgroundService::DEFAULT_COLOR;
234+
return $defaultColor;
235235
}
236236

237-
// If the user selected a specific colour
237+
// If the user selected a valid custom colour
238238
if (preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $themingBackground)) {
239239
return $themingBackground;
240240
}
@@ -245,11 +245,6 @@ public function getColorPrimary(): string {
245245
}
246246
}
247247

248-
// If the default color is not valid, return the default background one
249-
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
250-
return BackgroundService::DEFAULT_COLOR;
251-
}
252-
253248
// Finally, return the system global primary color
254249
return $defaultColor;
255250
}
@@ -259,9 +254,12 @@ public function getColorPrimary(): string {
259254
*/
260255
public function getDefaultColorPrimary(): string {
261256
$color = $this->config->getAppValue(Application::APP_ID, 'color');
257+
258+
// If the color is invalid, fallback to default
262259
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
263-
$color = '#0082c9';
260+
$color = BackgroundService::DEFAULT_COLOR;
264261
}
262+
265263
return $color;
266264
}
267265

tests/acceptance/features/app-theming.feature

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ Feature: app-theming
1313
And I see that the non-plain background color variable is eventually "#0082c9"
1414
When I set the "Color" parameter in the Theming app to "#C9C9C9"
1515
Then I see that the parameters in the Theming app are eventually saved
16-
And I see that the primary color is eventually "#00639a"
16+
# Default user background follows admin theming
17+
And I see that the primary color is eventually "#C9C9C9"
1718
And I see that the non-plain background color variable is eventually "#C9C9C9"
1819

1920
Scenario: resetting the color updates the primary color
@@ -27,5 +28,6 @@ Feature: app-theming
2728
And I see that the non-plain background color variable is eventually "#C9C9C9"
2829
When I reset the "Color" parameter in the Theming app to its default value
2930
Then I see that the parameters in the Theming app are eventually saved
30-
And I see that the primary color is eventually "#00639a"
31+
# Default user background follows admin theming
32+
And I see that the primary color is eventually "#0082c9"
3133
And I see that the non-plain background color variable is eventually "#0082c9"

0 commit comments

Comments
 (0)