Skip to content

Commit

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

Do not load Talk sidebar in public share page of folder shares
  • Loading branch information
nickvergessen authored Oct 22, 2019
2 parents 6dfce76 + 645c721 commit 7972bee
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/PublicShare/TemplateLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

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.
Expand All @@ -37,8 +40,10 @@
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);
});
}

Expand All @@ -47,14 +52,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->getNodeType() !== FileInfo::TYPE_FILE) {
return;
}

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

0 comments on commit 7972bee

Please sign in to comment.