Default to first application if no default app is set

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2023-09-26 14:40:14 +02:00
parent 6083d32a80
commit a4a3d94f05
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -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