Skip to content

Commit c23949d

Browse files
author
Julien Veyssier
committed
refs #22468 fix empty php array becoming an array instead of an object in UI
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
1 parent 2b192e7 commit c23949d

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

apps/dashboard/lib/Controller/DashboardController.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,12 @@ public function index(): TemplateResponse {
103103
'url' => $widget->getUrl()
104104
];
105105
}, $this->dashboardManager->getWidgets());
106-
$configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', '{}');
106+
$configStatuses = $this->config->getUserValue($this->userId, 'dashboard', 'statuses', '');
107107
$statuses = json_decode($configStatuses, true);
108+
// We avoid getting an empty array as it will not produce an object in UI's JS
109+
// It does not matter if some statuses are missing from the array, missing ones are considered enabled
110+
$statuses = ($statuses && count($statuses) > 0) ? $statuses : ['weather' => true];
111+
108112
$this->inititalStateService->provideInitialState('dashboard', 'panels', $widgets);
109113
$this->inititalStateService->provideInitialState('dashboard', 'statuses', $statuses);
110114
$this->inititalStateService->provideInitialState('dashboard', 'layout', $userLayout);

0 commit comments

Comments
 (0)