add apps sorter is user side (fix #160)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2022-11-04 21:07:44 +01:00
commit 52d88771d9
Signed by: deblan
GPG key ID: 579388D585F70417
6 changed files with 63 additions and 10 deletions

View file

@ -2,6 +2,7 @@
namespace OCA\SideMenu\Service;
use OC\User\User;
use OCP\L10N\IFactory;
/**
@ -110,11 +111,19 @@ class AppRepository
);
}
public function getOrderedApps()
public function getOrderedApps(?User $user = null)
{
$apps = $this->getVisibleApps();
$orders = $this->config->getAppValueArray('apps-order', '[]');
if (null !== $user && !$this->config->getAppValueBool('force', '0')) {
$userOrders = $this->config->getUserValueArray($user, 'apps-order', '[]');
if (!empty($userOrders)) {
$orders = $userOrders;
}
}
usort($apps, function ($a, $b) use ($orders) {
$ak = array_keys($orders, $a['id'])[0] ?? null;
$bk = array_keys($orders, $b['id'])[0] ?? null;