Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,10 @@ public function getColorPrimary(): string {
$themingBackground = $this->config->getUserValue($user->getUID(), Application::APP_ID, 'background', '');
// If the user selected the default background
if ($themingBackground === '') {
return BackgroundService::DEFAULT_COLOR;
return $defaultColor;
}

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

// If the default color is not valid, return the default background one
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $defaultColor)) {
return BackgroundService::DEFAULT_COLOR;
}

// Finally, return the system global primary color
return $defaultColor;
}
Expand All @@ -259,9 +254,12 @@ public function getColorPrimary(): string {
*/
public function getDefaultColorPrimary(): string {
$color = $this->config->getAppValue(Application::APP_ID, 'color');

// If the color is invalid, fallback to default
if (!preg_match('/^\#([0-9a-f]{3}|[0-9a-f]{6})$/i', $color)) {
$color = '#0082c9';
$color = BackgroundService::DEFAULT_COLOR;
}

return $color;
}

Expand Down
6 changes: 4 additions & 2 deletions tests/acceptance/features/app-theming.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Feature: app-theming
And I see that the non-plain background color variable is eventually "#0082c9"
When I set the "Color" parameter in the Theming app to "#C9C9C9"
Then I see that the parameters in the Theming app are eventually saved
And I see that the primary color is eventually "#006aa3"
# Default user background follows admin theming
And I see that the primary color is eventually "#C9C9C9"
And I see that the non-plain background color variable is eventually "#C9C9C9"

Scenario: resetting the color updates the primary color
Expand All @@ -23,9 +24,10 @@ Feature: app-theming
And I see that the color selector in the Theming app has loaded
And I set the "Color" parameter in the Theming app to "#C9C9C9"
And I see that the parameters in the Theming app are eventually saved
And I see that the primary color is eventually "#006aa3"
And I see that the primary color is eventually "#C9C9C9"
And I see that the non-plain background color variable is eventually "#C9C9C9"
When I reset the "Color" parameter in the Theming app to its default value
Then I see that the parameters in the Theming app are eventually saved
# Default user background follows admin theming
And I see that the primary color is eventually "#006aa3"
And I see that the non-plain background color variable is eventually "#0082c9"