Skip to content

Commit 708fa13

Browse files
mykh-hailosusnux
authored andcommitted
fix: move sanitize directly to sanitizeLayout
Signed-off-by: mykh-hailo <kristianderonta0205@gmail.com>
1 parent 5a8292f commit 708fa13

1 file changed

Lines changed: 13 additions & 23 deletions

File tree

apps/dashboard/lib/Service/DashboardService.php

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function __construct(
3131
*/
3232
public function getLayout(): array {
3333
$systemDefault = $this->appConfig->getAppValueString('layout', 'recommendations,spreed,mail,calendar');
34-
return $this->sanitizeStringList(
34+
return $this->sanitizeLayout(
3535
explode(',', $this->userConfig->getValueString($this->userId, 'dashboard', 'layout', $systemDefault)),
3636
);
3737
}
@@ -41,7 +41,18 @@ public function getLayout(): array {
4141
* @return list<string>
4242
*/
4343
public function sanitizeLayout(array $layout): array {
44-
return $this->sanitizeStringList($layout);
44+
$seen = [];
45+
$result = [];
46+
foreach ($layout as $value) {
47+
if ($value === '' || isset($seen[$value])) {
48+
continue;
49+
}
50+
51+
$seen[$value] = true;
52+
$result[] = $value;
53+
}
54+
55+
return $result;
4556
}
4657

4758
/**
@@ -80,25 +91,4 @@ public function getBirthdate(): string {
8091

8192
return $birthdate->getValue();
8293
}
83-
84-
/**
85-
* Keep insertion order while removing empty and duplicate values.
86-
*
87-
* @param list<string> $values
88-
* @return list<string>
89-
*/
90-
private function sanitizeStringList(array $values): array {
91-
$seen = [];
92-
$result = [];
93-
foreach ($values as $value) {
94-
if ($value === '' || isset($seen[$value])) {
95-
continue;
96-
}
97-
98-
$seen[$value] = true;
99-
$result[] = $value;
100-
}
101-
102-
return $result;
103-
}
10494
}

0 commit comments

Comments
 (0)