Skip to content

Commit

Permalink
Do not load Talk sidebar in public share page of folder shares
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
danxuliu committed Oct 22, 2019
1 parent b4f8bcf commit 645c721
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 645c721

Please sign in to comment.