From a4a3d94f058864d188e4daaa300f834ba3cba380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 26 Sep 2023 14:40:14 +0200 Subject: [PATCH] Default to first application if no default app is set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- lib/private/App/AppManager.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/private/App/AppManager.php b/lib/private/App/AppManager.php index 88044fbf7b6..9d07000c6f8 100644 --- a/lib/private/App/AppManager.php +++ b/lib/private/App/AppManager.php @@ -825,13 +825,26 @@ class AppManager implements IAppManager { public function getDefaultAppForUser(?IUser $user = null): string { // Set fallback to always-enabled files app $appId = 'files'; - $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', 'dashboard,files')); + $defaultApps = explode(',', $this->config->getSystemValueString('defaultapp', '')); $user ??= $this->userSession->getUser(); if ($user !== null) { $userDefaultApps = explode(',', $this->config->getUserValue($user->getUID(), 'core', 'defaultapp')); $defaultApps = array_filter(array_merge($userDefaultApps, $defaultApps)); + if (empty($defaultApps)) { + /* Fallback on user defined apporder */ + $customOrders = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR); + if (!empty($customOrders)) { + $customOrders = array_map('min', $customOrders); + asort($customOrders); + $defaultApps = array_keys($customOrders); + } + } + } + + if (empty($defaultApps)) { + $defaultApps = ['dashboard','files']; } // Find the first app that is enabled for the current user