From fff67ed9af47972d92b79385cb5cbc03d6ed0c26 Mon Sep 17 00:00:00 2001 From: Hampus Date: Thu, 8 Oct 2026 23:21:27 +0200 Subject: [PATCH] fix(desktop): fetch theme CSS via the local resource proxy (#3326) --- .../features/theme/components/modals/ThemeAcceptModal.tsx | 4 ++-- fluxer_app/src/features/theme/hooks/useThemeExists.ts | 4 ++-- fluxer_app/src/features/theme/utils/ThemeUtils.ts | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/fluxer_app/src/features/theme/components/modals/ThemeAcceptModal.tsx b/fluxer_app/src/features/theme/components/modals/ThemeAcceptModal.tsx index 0c4a45ee7..14b80b8ec 100644 --- a/fluxer_app/src/features/theme/components/modals/ThemeAcceptModal.tsx +++ b/fluxer_app/src/features/theme/components/modals/ThemeAcceptModal.tsx @@ -8,7 +8,7 @@ import {useArboriumHighlightedHtml} from '@app/features/code_highlighting/utils/ import {COPY_CODE_DESCRIPTOR, SOMETHING_WENT_WRONG_DESCRIPTOR} from '@app/features/i18n/utils/CommonMessageDescriptors'; import {Logger} from '@app/features/platform/utils/AppLogger'; import styles from '@app/features/theme/components/modals/ThemeAcceptModal.module.css'; -import {buildThemeCssProxyUrl} from '@app/features/theme/utils/ThemeUtils'; +import {buildThemeCssFetchUrl} from '@app/features/theme/utils/ThemeUtils'; import {Button} from '@app/features/ui/button/Button'; import * as ModalCommands from '@app/features/ui/commands/ModalCommands'; import * as ToastCommands from '@app/features/ui/commands/ToastCommands'; @@ -56,7 +56,7 @@ export const ThemeAcceptModal = observer(function ThemeAcceptModal({themeId, run setFetchStatus('loading'); setFetchError(null); try { - const themeUrl = buildThemeCssProxyUrl(runtimeSnapshot, themeId); + const themeUrl = buildThemeCssFetchUrl(runtimeSnapshot, themeId); if (!themeUrl) { throw new Error('Media endpoint not configured'); } diff --git a/fluxer_app/src/features/theme/hooks/useThemeExists.ts b/fluxer_app/src/features/theme/hooks/useThemeExists.ts index 044960fa8..4e988e4bc 100644 --- a/fluxer_app/src/features/theme/hooks/useThemeExists.ts +++ b/fluxer_app/src/features/theme/hooks/useThemeExists.ts @@ -2,7 +2,7 @@ import type {RuntimeConfigSnapshot} from '@app/features/app/state/InstanceSnapshotStore'; import {Logger} from '@app/features/platform/utils/AppLogger'; -import {buildThemeCssProxyUrl} from '@app/features/theme/utils/ThemeUtils'; +import {buildThemeCssFetchUrl} from '@app/features/theme/utils/ThemeUtils'; import {useEffect, useState} from 'react'; const logger = new Logger('useThemeExists'); @@ -15,7 +15,7 @@ export const useThemeExists = (themeId: string, runtimeSnapshot: RuntimeConfigSn let cancelled = false; const checkThemeExists = async () => { try { - const themeUrl = buildThemeCssProxyUrl(runtimeSnapshot, themeId); + const themeUrl = buildThemeCssFetchUrl(runtimeSnapshot, themeId); if (themeUrl == null) throw new Error('Media endpoint not configured'); const response = await fetch(themeUrl, {method: 'HEAD'}); if (!response.ok) throw new Error('Theme not found'); diff --git a/fluxer_app/src/features/theme/utils/ThemeUtils.ts b/fluxer_app/src/features/theme/utils/ThemeUtils.ts index 653426d94..50b30d072 100644 --- a/fluxer_app/src/features/theme/utils/ThemeUtils.ts +++ b/fluxer_app/src/features/theme/utils/ThemeUtils.ts @@ -3,7 +3,7 @@ import {type RuntimeConfigSnapshot, runtimeInstanceKey} from '@app/features/app/state/InstanceSnapshotStore'; import RuntimeConfig from '@app/features/app/state/RuntimeConfig'; import * as CodeLinkUtils from '@app/features/messaging/utils/CodeLinkUtils'; -import {buildMediaProxyURLForInstance} from '@app/features/messaging/utils/MediaProxyUtils'; +import {wrapDesktopLocalResourceURLForInstance} from '@app/features/messaging/utils/DesktopResourceUrl'; const OFFICIAL_THEME_URL_BASES = Object.freeze([ 'https://fluxer.app/theme', @@ -47,12 +47,12 @@ function buildThemeCssUrl(endpoint: string | null | undefined, themeId: string): return `${base}/themes/${themeId}.css`; } -export function buildThemeCssProxyUrl(snapshot: RuntimeConfigSnapshot, themeId: string): string | null { +export function buildThemeCssFetchUrl(snapshot: RuntimeConfigSnapshot, themeId: string): string | null { const rawUrl = buildThemeCssUrl(snapshot.mediaEndpoint, themeId); if (!rawUrl) return null; const instanceKey = runtimeInstanceKey(snapshot); if (instanceKey == null) { throw new Error(`Theme runtime has no usable instance key (apiEndpoint: "${snapshot.apiEndpoint}")`); } - return buildMediaProxyURLForInstance(rawUrl, instanceKey); + return wrapDesktopLocalResourceURLForInstance(rawUrl, instanceKey); }