From 37e3115cb472a8d8b16be183c045220835e1fbef Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 15 Aug 2023 12:11:08 +0200 Subject: [PATCH] don't always add core/common and core/main during "sorting" Signed-off-by: Robin Appelman --- core/Listener/BeforeTemplateRenderedListener.php | 6 ++++++ lib/public/Util.php | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/core/Listener/BeforeTemplateRenderedListener.php b/core/Listener/BeforeTemplateRenderedListener.php index c453d010a4c..95adfc61ad9 100644 --- a/core/Listener/BeforeTemplateRenderedListener.php +++ b/core/Listener/BeforeTemplateRenderedListener.php @@ -49,6 +49,12 @@ class BeforeTemplateRenderedListener implements IEventListener { \OC_Util::addStyle('server', null, true); + if ($event instanceof BeforeLoginTemplateRenderedEvent) { + // todo: make login work without these + Util::addScript('core', 'common'); + Util::addScript('core', 'main'); + } + if ($event instanceof BeforeTemplateRenderedEvent) { // include common nextcloud webpack bundle Util::addScript('core', 'common'); diff --git a/lib/public/Util.php b/lib/public/Util.php index 63ed9e835c7..1d03c35a9b7 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -212,7 +212,12 @@ class Util { $sortedScripts = $sortedScripts ? array_merge(...array_values(($sortedScripts))) : []; // Override core-common and core-main order - array_unshift($sortedScripts, 'core/js/common', 'core/js/main'); + if (in_array('core/js/main', $sortedScripts)) { + array_unshift($sortedScripts, 'core/js/main'); + } + if (in_array('core/js/common', $sortedScripts)) { + array_unshift($sortedScripts, 'core/js/common'); + } return array_unique($sortedScripts); } -- 2.39.5