Skip to content

Commit b17d518

Browse files
Merge pull request #58959 from nextcloud/bugfix/spreed-16678/load-custom-app-order-earlier
fix(apporder): Load custom app order before resolving closures
2 parents 46f61ca + 58619b2 commit b17d518

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/private/NavigationManager.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class NavigationManager implements INavigationManager {
3636
protected array $unreadCounters = [];
3737
protected bool $init = false;
3838
/** User defined app order (cached for the `add` function) */
39-
private array $customAppOrder;
39+
private ?array $customAppOrder = null;
4040

4141
public function __construct(
4242
protected IAppManager $appManager,
@@ -182,6 +182,15 @@ public function getActiveEntry(): ?string {
182182
}
183183

184184
private function init(bool $resolveClosures = true): void {
185+
if ($this->customAppOrder === null) {
186+
if ($this->userSession->isLoggedIn()) {
187+
$user = $this->userSession->getUser();
188+
$this->customAppOrder = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR);
189+
} else {
190+
$this->customAppOrder = [];
191+
}
192+
}
193+
185194
if ($resolveClosures) {
186195
while ($c = array_pop($this->closureEntries)) {
187196
$this->add($c());
@@ -302,10 +311,8 @@ private function init(bool $resolveClosures = true): void {
302311
if ($this->userSession->isLoggedIn()) {
303312
$user = $this->userSession->getUser();
304313
$apps = $this->appManager->getEnabledAppsForUser($user);
305-
$this->customAppOrder = json_decode($this->config->getUserValue($user->getUID(), 'core', 'apporder', '[]'), true, flags:JSON_THROW_ON_ERROR);
306314
} else {
307315
$apps = $this->appManager->getEnabledApps();
308-
$this->customAppOrder = [];
309316
}
310317

311318
foreach ($apps as $app) {

0 commit comments

Comments
 (0)