summaryrefslogtreecommitdiffstats
path: root/lib/Files
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-12-18 11:50:23 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-12-18 11:50:23 +0100
commitca03cff331ea759368e8ec2d44b35bb4bffdbeac (patch)
treebbd2b08ef70d258f73b4721eb5376ed81d5b95de /lib/Files
parent7b7162891921e20ce4279c236cde70b18e731ac8 (diff)
Unify new LoadSidebarListener with previous TemplateLoader
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib/Files')
-rw-r--r--lib/Files/TemplateLoader.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php
index 2d29bd2b9..18592a77b 100644
--- a/lib/Files/TemplateLoader.php
+++ b/lib/Files/TemplateLoader.php
@@ -23,34 +23,41 @@ declare(strict_types=1);
namespace OCA\Talk\Files;
+use OCA\Files\Event\LoadSidebar;
+use OCA\Talk\AppInfo\Application;
+use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
+use OCP\EventDispatcher\IEventListener;
use OCP\Util;
/**
* Helper class to add the Talk UI to the sidebar of the Files app.
*/
-class TemplateLoader {
+class TemplateLoader implements IEventListener {
public static function register(IEventDispatcher $dispatcher): void {
- $dispatcher->addListener('OCA\Files::loadAdditionalScripts', static function() {
- self::loadTalkSidebarForFilesApp();
- });
+ $dispatcher->addServiceListener(LoadSidebar::class, TemplateLoader::class);
}
/**
* Loads the Talk UI in the sidebar of the Files app.
*
- * This method should be called when loading additional scripts for the
+ * This method should be called when handling the LoadSidebar event of the
* Files app.
*/
- public static function loadTalkSidebarForFilesApp(): void {
+ public function handle(Event $event): void {
+ if (!($event instanceof LoadSidebar)) {
+ return;
+ }
+
$config = \OC::$server->getConfig();
if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
return;
}
- Util::addStyle('spreed', 'merged-files');
- Util::addScript('spreed', 'merged-files');
+ Util::addStyle(Application::APP_ID, 'merged-files');
+ Util::addScript(Application::APP_ID, 'files-sidebar-tab');
+ Util::addScript(Application::APP_ID, 'talk-chat-tab');
}
}