From e2aea3c0af3ec3f98658e4396a7893dd2a9559f6 Mon Sep 17 00:00:00 2001 From: Richard Steinmetz Date: Wed, 27 Nov 2024 14:41:33 +0100 Subject: [PATCH] fixup! feat: add availability action to the contacts menu --- lib/AppInfo/Application.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 7024fea86..03c39d259 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -23,6 +23,8 @@ use OCP\ServerVersion; use OCP\User\Events\UserDeletedEvent; use OCP\Util; +use Psr\Container\ContainerExceptionInterface; +use Psr\Container\ContainerInterface; use function method_exists; class Application extends App implements IBootstrap { @@ -59,9 +61,19 @@ public function register(IRegistrationContext $context): void { * @inheritDoc */ public function boot(IBootContext $context): void { + $this->addContactsMenuScript($context->getServerContainer()); + } + + private function addContactsMenuScript(ContainerInterface $container): void { + // ServerVersion was added in 31, but we don't care about older versions anyway + try { + /** @var ServerVersion $serverVersion */ + $serverVersion = $container->get(ServerVersion::class); + } catch (ContainerExceptionInterface $e) { + return; + } + // TODO: drop condition once we only support Nextcloud >= 31 - /** @var ServerVersion $serverVersion */ - $serverVersion = $context->getServerContainer()->get(ServerVersion::class); if ($serverVersion->getMajorVersion() >= 31) { // The contacts menu/avatar is potentially shown everywhere so an event based loading // mechanism doesn't make sense here