diff --git a/lib/Service/InitialStateService.php b/lib/Service/InitialStateService.php index e9d2a78b7c..caafc07875 100644 --- a/lib/Service/InitialStateService.php +++ b/lib/Service/InitialStateService.php @@ -28,6 +28,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; @@ -39,6 +40,7 @@ class InitialStateService { public function __construct( private IInitialState $initialState, private AppConfig $appConfig, + private ImageManager $imageManager, private CapabilitiesService $capabilitiesService, private IURLGenerator $urlGenerator, private Defaults $themingDefaults, @@ -101,15 +103,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 f374a9570d..e02e5c9c3f 100644 --- a/src/helpers/coolParameters.js +++ b/src/helpers/coolParameters.js @@ -162,9 +162,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') diff --git a/tests/stub.phpstub b/tests/stub.phpstub index 9dda632f24..107cd2fde9 100644 --- a/tests/stub.phpstub +++ b/tests/stub.phpstub @@ -79,6 +79,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() { }