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