perf: Register notifier and resource listener lazy

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-02-09 10:03:38 +01:00
parent 2f58f9c1c5
commit 403a4dc294
2 changed files with 36 additions and 17 deletions

View File

@@ -0,0 +1,31 @@
<?php
namespace OCA\Deck\Listeners;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IRequest;
use OCP\Util;
/** @template-implements IEventListener<Event|LoadAdditionalScriptsEvent> */
class ResourceAdditionalScriptsListener implements IEventListener {
private IRequest $request;
public function __construct(IRequest $request) {
$this->request = $request;
}
public function handle(Event $event): void {
if (!$event instanceof LoadAdditionalScriptsEvent) {
return;
}
if (strpos($this->request->getPathInfo(), '/call/') === 0) {
// Talk integration has its own entrypoint which already includes collections handling
return;
}
Util::addScript('deck', 'deck-collections');
}
}