Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable17] Do not load Talk sidebar in public share page of folder shares #2340

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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