add custom apps sorting

This commit is contained in:
Simon Vieille 2022-10-21 17:59:41 +02:00
commit 84c620637e
Signed by untrusted user: deblan
GPG key ID: 579388D585F70417
8 changed files with 85 additions and 1 deletions

View file

@ -105,4 +105,23 @@ class AppRepository
return $visibleApps;
}
public function getTopMenuOrderedApps()
{
$apps = $this->getVisibleApps();
$orders = $this->config->getAppValueArray('top-menu-apps-order', '[]');
usort($apps, function ($a, $b) use ($orders) {
$ak = array_keys($orders, $a['id'])[0] ?? null;
$bk = array_keys($orders, $b['id'])[0] ?? null;
if ($ak === null || $bk === null) {
return ($a['name'] < $b['name']) ? -1 : 1;
}
return $ak < $bk ? -1 : 1;
});
return $apps;
}
}