From 6b2d1b20709177a4c56fd7e45a00db5670bec1e7 Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Tue, 8 Oct 2024 14:52:55 -0400 Subject: [PATCH 1/2] fix: pass proper logo as custom logo Signed-off-by: Elizabeth Danzberger --- lib/Service/InitialStateService.php | 13 ++++++++----- src/helpers/coolParameters.js | 3 ++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Service/InitialStateService.php b/lib/Service/InitialStateService.php index 8e2550204b..910db97733 100644 --- a/lib/Service/InitialStateService.php +++ b/lib/Service/InitialStateService.php @@ -11,6 +11,7 @@ use OCA\Richdocuments\AppConfig; use OCA\Richdocuments\AppInfo\Application; use OCA\Richdocuments\Db\Wopi; +use OCA\Theming\ImageManager; use OCP\AppFramework\Services\IInitialState; use OCP\Defaults; use OCP\IConfig; @@ -22,6 +23,7 @@ class InitialStateService { public function __construct( private IInitialState $initialState, private AppConfig $appConfig, + private ImageManager $imageManager, private CapabilitiesService $capabilitiesService, private IURLGenerator $urlGenerator, private Defaults $themingDefaults, @@ -84,15 +86,16 @@ private function provideOptions(): void { 'UIMode' => $this->config->getAppValue(Application::APPNAME, 'uiDefaults-UIMode', 'notebookbar') ]); - $logoSet = $this->config->getAppValue('theming', 'logoheaderMime', '') !== ''; + $logoType = 'logoheader'; + $logoSet = $this->imageManager->hasImage($logoType); if (!$logoSet) { - $logoSet = $this->config->getAppValue('theming', 'logoMime', '') !== ''; + $logoType = 'logo'; + $logoSet = $this->imageManager->hasImage($logoType); } - $this->initialState->provideInitialState('theming-customLogo', ($logoSet ? - $this->urlGenerator->getAbsoluteURL($this->themingDefaults->getLogo()) - : false)); + $logo = $logoSet ? $this->imageManager->getImageUrlAbsolute($logoType) : false; + $this->initialState->provideInitialState('theming-customLogo', $logo); $this->initialState->provideInitialState('open_local_editor', $this->config->getAppValue(Application::APPNAME, 'open_local_editor', 'yes') === 'yes'); } } diff --git a/src/helpers/coolParameters.js b/src/helpers/coolParameters.js index 2508daf221..cb31826628 100644 --- a/src/helpers/coolParameters.js +++ b/src/helpers/coolParameters.js @@ -145,9 +145,10 @@ const generateCSSVarTokens = () => { // cleanup theme elements after extracting property values lightElement.remove() darkElement.remove() + const customLogo = loadState('richdocuments', 'theming-customLogo', false) if (customLogo) { - str += `--nc-custom-logo=${window.OCA?.Theming?.cacheBuster ?? 0};` + str += `--nc-custom-logo=${encodeURIComponent(customLogo)};` } const rootEl = document.querySelector(':root') From 8cbdbf835731532b9b3945fad6fffc4285a8505d Mon Sep 17 00:00:00 2001 From: Elizabeth Danzberger Date: Tue, 8 Oct 2024 15:03:35 -0400 Subject: [PATCH 2/2] chore: add `ImageManager` to php stub Signed-off-by: Elizabeth Danzberger --- tests/stub.phpstub | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/stub.phpstub b/tests/stub.phpstub index 55ae13a41a..93f111fda9 100644 --- a/tests/stub.phpstub +++ b/tests/stub.phpstub @@ -82,6 +82,35 @@ namespace OCA\Files_Sharing\Event { } } +namespace OCA\Theming { + use OCA\Theming\Service\BackgroundService; + use OCA\Files\IAppData; + use OCP\ICacheFactory; + use OCP\IConfig; + use OCP\ITempManager; + use OCP\IURLGenerator; + use PSR\Log\LoggerInterface; + + class ImageManager { + public function __construct( + IConfig $config, + IAppData $appData, + IURLGenerator $urlGenerator, + ICacheFactory $cacheFactory, + LoggerInterface $logger, + ITempManager $tempManager, + BackgroundService $backgroundService + ) { + } + + public function hasImage(string $key): bool { + } + + public function getImageUrlAbsolute(string $key): string { + } + } +} + class OC_Helper { public static function getFileTemplateManager() { }