Skip to content

Commit

Permalink
Merge pull request #2340 from nextcloud/backport/2339/stable17-do-not…
Browse files Browse the repository at this point in the history
…-load-talk-sidebar-in-public-share-page-of-folder-shares

[stable17] Do not load Talk sidebar in public share page of folder shares
  • Loading branch information
nickvergessen authored Oct 22, 2019
2 parents 142f91e + cf3eea4 commit 7ad8ba1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions lib/PublicShare/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@

namespace OCA\Spreed\PublicShare;

use OCP\Files\FileInfo;
use OCP\Share\IShare;
use OCP\Util;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\GenericEvent;

/**
* Helper class to extend the "publicshare" template from the server.
Expand All @@ -37,8 +41,13 @@
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(Event $event) {
/** @var IShare $share */
$share = null;
if ($event instanceof GenericEvent) {
$share = $event->getArgument('share');
}
self::loadTalkSidebarUi($share);
});
}

Expand All @@ -47,14 +56,20 @@ public static function register(EventDispatcherInterface $dispatcher): void {
*
* 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 || $share->getNodeType() !== FileInfo::TYPE_FILE) {
return;
}

Util::addStyle('spreed', 'merged-public-share');
Util::addScript('spreed', 'merged-public-share');
}
Expand Down

0 comments on commit 7ad8ba1

Please sign in to comment.