-
-
Notifications
You must be signed in to change notification settings - Fork 5k
fix(NavigationManager): only resolve navigations of booted apps #61120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
| /** | ||
| * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| namespace OCA\Profile\Listener; | ||
|
|
||
| use OCA\Settings\AppInfo\Application; | ||
| use OCP\App\IAppManager; | ||
| use OCP\EventDispatcher\Event; | ||
| use OCP\EventDispatcher\IEventListener; | ||
| use OCP\IL10N; | ||
| use OCP\INavigationManager; | ||
| use OCP\IURLGenerator; | ||
| use OCP\IUserSession; | ||
| use OCP\Navigation\Events\LoadAdditionalEntriesEvent; | ||
|
|
||
| /** @template-implements IEventListener<LoadAdditionalEntriesEvent> */ | ||
| class LoadAdditionalEntriesListener implements IEventListener { | ||
|
|
||
| public function __construct( | ||
| private readonly IL10N $l10n, | ||
| private readonly IAppManager $appManger, | ||
| private readonly INavigationManager $navigationManager, | ||
| private readonly IURLGenerator $urlGenerator, | ||
| private readonly IUserSession $userSession, | ||
| ) { | ||
| } | ||
|
|
||
| #[\Override] | ||
| public function handle(Event $event): void { | ||
| if (!($event instanceof LoadAdditionalEntriesEvent)) { | ||
| return; | ||
| } | ||
|
|
||
| if (!$this->userSession->isLoggedIn()) { | ||
| return; | ||
| } | ||
|
Comment on lines
+39
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not needed, there is already the null check on $user in the child function |
||
|
|
||
| if ($this->appManger->isAppLoaded(Application::APP_ID)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is it needed to check that? Could you add a comment explaining we need the settings application to be loaded and why. (reading the code it’s not obvious this is the settings application) |
||
| $this->registerNavigationEntries(); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| private function registerNavigationEntries(): void { | ||
| $user = $this->userSession->getUser(); | ||
| if ($user === null) { | ||
| return; | ||
| } | ||
|
|
||
| $this->navigationManager->add([ | ||
| 'type' => 'settings', | ||
| 'id' => 'profile', | ||
| 'order' => 1, | ||
| 'href' => $this->urlGenerator->linkToRoute( | ||
| 'profile.ProfilePage.index', | ||
| ['targetUserId' => $user->getUID()], | ||
| ), | ||
| 'name' => $this->l10n->t('View profile'), | ||
| ]); | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.