Skip to content

Commit

Permalink
Register default share template provider
Browse files Browse the repository at this point in the history
+ Properly return the first provider in the share template factory

Signed-off-by: Louis Chemineau <[email protected]>
  • Loading branch information
artonge committed Dec 22, 2022
1 parent 1d1f16e commit 8df671e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions apps/files_sharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use OCA\Files_Sharing\Notification\Notifier;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar;
use OCA\Files_Sharing\DefaultShareDisplayTemplateProvider;
use OCP\Files\Event\BeforeDirectGetEvent;
use OCA\Files_Sharing\ShareBackend\File;
use OCA\Files_Sharing\ShareBackend\Folder;
Expand Down Expand Up @@ -131,6 +132,10 @@ public function boot(IBootContext $context): void {
* Always add main sharing script
*/
Util::addScript(self::APP_ID, 'main');

$container = $context->getServerContainer();
$factory = $container->get(\OCP\Share\IShareDisplayTemplateFactory::class);
$factory->registerDisplayShareTemplate(DefaultShareDisplayTemplateProvider::class);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/private/Share20/ShareDisplayTemplateFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public function getTemplateProvider(IShare $share): IShareDisplayTemplateProvide
);
usort($providers, fn (IShareDisplayTemplateProvider $a, IShareDisplayTemplateProvider $b) => $b->getPriority() - $a->getPriority());
$filteredProviders = array_filter($providers, fn (IShareDisplayTemplateProvider $provider) => $provider->shouldRespond($share));
return $filteredProviders[0];
return array_shift($filteredProviders);
}
}

0 comments on commit 8df671e

Please sign in to comment.