summaryrefslogtreecommitdiffstats
path: root/apps/comments/lib
diff options
context:
space:
mode:
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-11-04 19:25:42 +0100
committerJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>2019-11-04 23:31:39 +0100
commit7ba5f39dbd96d72d4a8a7236cd146e546eb3b44b (patch)
treeff6f3ca29c3d79f6b8c6824c28c7213449773835 /apps/comments/lib
parent13960b69da2593dcfb0cbaef222ee8b9a33142c0 (diff)
downloadnextcloud-server-7ba5f39dbd96d72d4a8a7236cd146e546eb3b44b.tar.gz
nextcloud-server-7ba5f39dbd96d72d4a8a7236cd146e546eb3b44b.zip
Fix comments app init and LoadSidebar event
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r--apps/comments/lib/AppInfo/Application.php20
-rw-r--r--apps/comments/lib/Listener/LoadAdditionalScripts.php6
-rw-r--r--apps/comments/lib/Listener/LoadSidebarScripts.php45
3 files changed, 64 insertions, 7 deletions
diff --git a/apps/comments/lib/AppInfo/Application.php b/apps/comments/lib/AppInfo/Application.php
index 793d1e9f7be..e2f79c96381 100644
--- a/apps/comments/lib/AppInfo/Application.php
+++ b/apps/comments/lib/AppInfo/Application.php
@@ -1,8 +1,9 @@
<?php
/**
- *
+ * @copyright Copyright (c) 2016, Arthur Schiwon <blizzz@arthur-schiwon.de>
*
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
@@ -27,33 +28,39 @@ use OCA\Comments\Controller\Notifications;
use OCA\Comments\EventHandler;
use OCA\Comments\JSSettingsHelper;
use OCA\Comments\Listener\LoadAdditionalScripts;
+use OCA\Comments\Listener\LoadSidebarScripts;
use OCA\Comments\Notification\Notifier;
use OCA\Comments\Search\Provider;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
+use OCA\Files\Event\LoadSidebar;
use OCP\AppFramework\App;
use OCP\Comments\CommentsEntityEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Util;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class Application extends App {
+ const APP_ID = 'comments';
+
public function __construct (array $urlParams = array()) {
- parent::__construct('comments', $urlParams);
+ parent::__construct(self::APP_ID, $urlParams);
$container = $this->getContainer();
$container->registerAlias('NotificationsController', Notifications::class);
$jsSettingsHelper = new JSSettingsHelper($container->getServer());
Util::connectHook('\OCP\Config', 'js', $jsSettingsHelper, 'extend');
+
+ $this->register();
}
- public function register() {
+ private function register() {
$server = $this->getContainer()->getServer();
/** @var IEventDispatcher $newDispatcher */
$dispatcher = $server->query(IEventDispatcher::class);
- $this->registerSidebarScripts($dispatcher);
+
+ $this->registerEventsScripts($dispatcher);
$this->registerDavEntity($dispatcher);
$this->registerNotifier();
$this->registerCommentsEventHandler();
@@ -61,8 +68,9 @@ class Application extends App {
$server->getSearch()->registerProvider(Provider::class, ['apps' => ['files']]);
}
- protected function registerSidebarScripts(IEventDispatcher $dispatcher) {
+ protected function registerEventsScripts(IEventDispatcher $dispatcher) {
$dispatcher->addServiceListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScripts::class);
+ $dispatcher->addServiceListener(LoadSidebar::class, LoadSidebarScripts::class);
}
protected function registerDavEntity(IEventDispatcher $dispatcher) {
diff --git a/apps/comments/lib/Listener/LoadAdditionalScripts.php b/apps/comments/lib/Listener/LoadAdditionalScripts.php
index b1e9447beab..a9c5c18a7c1 100644
--- a/apps/comments/lib/Listener/LoadAdditionalScripts.php
+++ b/apps/comments/lib/Listener/LoadAdditionalScripts.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
* @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
*
* @author Roeland Jago Douma <roeland@famdouma.nl>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
*
* @license GNU AGPL version 3 or any later version
*
@@ -24,6 +25,7 @@ declare(strict_types=1);
namespace OCA\Comments\Listener;
+use OCA\Comments\AppInfo\Application;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
@@ -35,7 +37,9 @@ class LoadAdditionalScripts implements IEventListener {
return;
}
- Util::addScript('comments', 'comments');
+ // TODO: make sure to only include the sidebar script when
+ // we properly split it between files list and sidebar
+ Util::addScript(Application::APP_ID, 'comments');
}
}
diff --git a/apps/comments/lib/Listener/LoadSidebarScripts.php b/apps/comments/lib/Listener/LoadSidebarScripts.php
new file mode 100644
index 00000000000..b0468b2dd2e
--- /dev/null
+++ b/apps/comments/lib/Listener/LoadSidebarScripts.php
@@ -0,0 +1,45 @@
+<?php
+declare(strict_types=1);
+/**
+ * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
+ *
+ * @author Roeland Jago Douma <roeland@famdouma.nl>
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCA\Comments\Listener;
+
+use OCA\Comments\AppInfo\Application;
+use OCA\Files\Event\LoadSidebar;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use OCP\Util;
+
+class LoadSidebarScripts implements IEventListener {
+ public function handle(Event $event): void {
+ if (!($event instanceof LoadSidebar)) {
+ return;
+ }
+
+ // TODO: make sure to only include the sidebar script when
+ // we properly split it between files list and sidebar
+ Util::addScript(Application::APP_ID, 'comments');
+ }
+
+}