From 708fa134280374597569e4dae6ef11ecc880541e Mon Sep 17 00:00:00 2001 From: mykh-hailo Date: Tue, 31 Mar 2026 12:00:07 +0200 Subject: [PATCH] fix: move sanitize directly to sanitizeLayout Signed-off-by: mykh-hailo --- .../lib/Service/DashboardService.php | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/apps/dashboard/lib/Service/DashboardService.php b/apps/dashboard/lib/Service/DashboardService.php index 46c46f54eb0..c94617d6941 100644 --- a/apps/dashboard/lib/Service/DashboardService.php +++ b/apps/dashboard/lib/Service/DashboardService.php @@ -31,7 +31,7 @@ class DashboardService { */ public function getLayout(): array { $systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar'); - return $this->sanitizeStringList( + return $this->sanitizeLayout( explode(',', $this->userConfig->getValueString($this->userId, 'dashboard', 'layout', $systemDefault)), ); } @@ -41,7 +41,18 @@ class DashboardService { * @return list */ public function sanitizeLayout(array $layout): array { - return $this->sanitizeStringList($layout); + $seen = []; + $result = []; + foreach ($layout as $value) { + if ($value === '' || isset($seen[$value])) { + continue; + } + + $seen[$value] = true; + $result[] = $value; + } + + return $result; } /** @@ -80,25 +91,4 @@ class DashboardService { return $birthdate->getValue(); } - - /** - * Keep insertion order while removing empty and duplicate values. - * - * @param list $values - * @return list - */ - private function sanitizeStringList(array $values): array { - $seen = []; - $result = []; - foreach ($values as $value) { - if ($value === '' || isset($seen[$value])) { - continue; - } - - $seen[$value] = true; - $result[] = $value; - } - - return $result; - } }