diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-10-21 11:44:30 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2019-10-22 14:15:17 +0300 |
commit | 645c72158189ce4553bb48a5f7d1bc7bed24d4b1 (patch) | |
tree | 075f75e9272a257197f78f1c4062b2dc7a198561 /lib | |
parent | b4f8bcfbb375f0daef31163c9f7337e9e32b2e80 (diff) |
Do not load Talk sidebar in public share page of folder shares
The Talk sidebar is only shown for file shares, so there is no need to
load it for folder shares. Moreover, this also prevents some of the
hacks used to show the Talk sidebar to mess with the layout used for
folders.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicShare/TemplateLoader.php | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/PublicShare/TemplateLoader.php b/lib/PublicShare/TemplateLoader.php index 19e3a5590..a3906e99c 100644 --- a/lib/PublicShare/TemplateLoader.php +++ b/lib/PublicShare/TemplateLoader.php @@ -24,8 +24,11 @@ declare(strict_types=1); namespace OCA\Talk\PublicShare; +use OCP\Files\FileInfo; +use OCP\Share\IShare; use OCP\Util; use Symfony\Component\EventDispatcher\EventDispatcherInterface; +use Symfony\Component\EventDispatcher\GenericEvent; /** * Helper class to extend the "publicshare" template from the server. @@ -37,8 +40,10 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; class TemplateLoader { public static function register(EventDispatcherInterface $dispatcher): void { - $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function() { - self::loadTalkSidebarUi(); + $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function(GenericEvent $event) { + /** @var IShare $share */ + $share = $event->getArgument('share'); + self::loadTalkSidebarUi($share); }); } @@ -47,14 +52,20 @@ class TemplateLoader { * * This method should be called when loading additional scripts for the * public share page of the server. + * + * @param IShare $share */ - public static function loadTalkSidebarUi(): void { + public static function loadTalkSidebarUi(IShare $share): void { $config = \OC::$server->getConfig(); if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1' || $config->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') { return; } + if ($share->getNodeType() !== FileInfo::TYPE_FILE) { + return; + } + Util::addStyle('spreed', 'merged-public-share'); Util::addScript('spreed', 'merged-public-share'); } |