fix compatibility with the option 'hide-when-no-apps'

This commit is contained in:
Simon Vieille 2020-08-12 14:06:52 +02:00
commit 9d9afff08d
Signed by untrusted user: deblan
GPG key ID: 03383D15A1D31745
3 changed files with 18 additions and 3 deletions

View file

@ -27,6 +27,8 @@ use OCP\IL10N;
use OCP\IRequest;
use OCP\L10N\IFactory;
use OC\URLGenerator;
use OC;
use OCP\IUserSession;
class NavController extends Controller
{
@ -96,10 +98,17 @@ class NavController extends Controller
$currentLanguage = substr($this->l10nFactory->findLanguage(), 0, 2);
$categoriesLabels = $this->categoryFetcher->get();
$externalSitesInTopMenu = (bool) $this->config->getAppValue('side_menu', 'external-sites-in-top-menu', 0);
$user = OC::$server[IUserSession::class]->getUser();
$appsCategories = [];
$categoriesAppsCount = [];
$items = [];
if (!$user) {
return new JSONResponse([
'items' => $items,
]);
}
foreach ($categoriesLabels as $k => $category) {
$categoriesLabels[$category['id']] = $category['translations'][$currentLanguage]['name'] ?? $category['translations']['en']['name'];