Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
fix: logo color not applying on refreshes
Kyle Mendellfe539851d621
diff --git a/backend/internal/huma/handlers/appimages.go b/backend/internal/huma/handlers/appimages.goindex 4293b73b2..879d1028a 100644--- a/backend/internal/huma/handlers/appimages.go+++ b/backend/internal/huma/handlers/appimages.go@@ -17,7 +17,8 @@ type AppImagesHandler struct {// --- Huma Input/Output Wrappers ---type GetLogoInput struct {- Full bool `query:"full" default:"false" doc:"Return full logo instead of icon"`+ Full bool `query:"full" default:"false" doc:"Return full logo instead of icon"`+ Color string `query:"color" doc:"Optional accent color override for preview (e.g., 'oklch(0.65 0.2 150)')"`}type GetAppImageOutput struct {@@ -80,7 +81,7 @@ func (h *AppImagesHandler) GetLogo(ctx context.Context, input *GetLogoInput) (*Gname = "logo-full"}- return h.getImage(name)+ return h.getImageWithColor(name, input.Color)}// GetLogoEmail returns the application logo image for emails (PNG).@@ -111,13 +112,21 @@ func (h *AppImagesHandler) GetDefaultProfile(ctx context.Context, input *struct{}func (h *AppImagesHandler) getImage(name string) (*GetAppImageOutput, error) {- imageData, mimeType, err := h.appImagesService.GetImage(name)+ return h.getImageWithColor(name, "")+}++func (h *AppImagesHandler) getImageWithColor(name string, colorOverride string) (*GetAppImageOutput, error) {+ imageData, mimeType, err := h.appImagesService.GetImageWithColor(name, colorOverride)if err != nil {return nil, huma.Error500InternalServerError((&common.ImageRetrievalError{Err: err}).Error())}- // Cache for 15 minutes, stale-while-revalidate for 24 hours+ // If color override is provided, don't cache (for preview purposes)+ // Otherwise cache for 15 minutes with stale-while-revalidate for 24 hourscacheControl := "public, max-age=900, stale-while-revalidate=86400"+ if colorOverride != "" {+ cacheControl = "no-cache, no-store, must-revalidate"+ }return &GetAppImageOutput{ContentType: mimeType,diff --git a/backend/internal/services/app_images_service.go b/backend/internal/services/app_images_service.goindex 7d7cfe1b9..c74a3da2d 100644--- a/backend/internal/services/app_images_service.go+++ b/backend/internal/services/app_images_service.go@@ -59,6 +59,10 @@ func NewApplicationImagesService(embeddedFS embed.FS, settingsService *SettingsS}func (s *ApplicationImagesService) GetImage(name string) ([]byte, string, error) {+ return s.GetImageWithColor(name, "")+}++func (s *ApplicationImagesService) GetImageWithColor(name string, colorOverride string) ([]byte, string, error) {s.mu.RLock()data, ok := s.imageData[name]mimeType := s.mimeTypes[name]@@ -70,30 +74,36 @@ func (s *ApplicationImagesService) GetImage(name string) ([]byte, string, error)// Apply dynamic color replacement for logo SVGsif (name == "logo" || name == "logo-full") && mimeType == "image/svg+xml" {- data = s.applyAccentColorToSVG(data)+ data = s.applyAccentColorToSVG(data, colorOverride)}return data, mimeType, nil}-func (s *ApplicationImagesService) applyAccentColorToSVG(svgData []byte) []byte {- // Get accent color from settings- cfg := s.settingsService.GetSettingsConfig()- if cfg == nil {- return svgData+func (s *ApplicationImagesService) applyAccentColorToSVG(svgData []byte, colorOverride string) []byte {+ var accentColor string++ // Use color override if provided, otherwise get from settings+ if colorOverride != "" {+ accentColor = colorOverride+ } else {+ cfg := s.settingsService.GetSettingsConfig()+ if cfg != nil {+ accentColor = cfg.AccentColor.Value+ }}- accentColor := cfg.AccentColor.Valueif accentColor == "" || accentColor == "default" {accentColor = "oklch(0.606 0.25 292.717)" // Default purple}// Replace the hardcoded purple color with the accent color- // The SVG uses .st0{fill:#6D28D9;} which we'll replace+ // The SVG uses .st0{fill:#6d28d9} which we'll replace (case-insensitive)svgStr := string(svgData)- // Replace hex color in style tag+ // Replace hex color in style tag (handle both cases)svgStr = strings.ReplaceAll(svgStr, "fill:#6D28D9", fmt.Sprintf("fill:%s", accentColor))+ svgStr = strings.ReplaceAll(svgStr, "fill:#6d28d9", fmt.Sprintf("fill:%s", accentColor))return []byte(svgStr)}diff --git a/frontend/src/lib/stores/config-store.ts b/frontend/src/lib/stores/config-store.tsindex 4d1d3f2ef..f3c0807b9 100644--- a/frontend/src/lib/stores/config-store.ts+++ b/frontend/src/lib/stores/config-store.ts@@ -1,12 +1,20 @@import { settingsService } from '$lib/services/settings-service';import type { Settings } from '$lib/types/settings.type';import { applyAccentColor } from '$lib/utils/accent-color-util';-import { writable } from 'svelte/store';+import { bustLogoCache } from '$lib/utils/image.util';+import { get, writable } from 'svelte/store';const settingsStore = writable<Settings>();const reload = async () => {+ const previousSettings = get(settingsStore);const settings = await settingsService.getSettings();++ // Bust logo cache if accent color changed+ if (previousSettings && previousSettings.accentColor !== settings.accentColor) {+ bustLogoCache();+ }+set(settings);};diff --git a/frontend/src/lib/utils/image.util.ts b/frontend/src/lib/utils/image.util.tsindex 2653a6006..41fec8a78 100644--- a/frontend/src/lib/utils/image.util.ts+++ b/frontend/src/lib/utils/image.util.ts@@ -1,21 +1,38 @@-import settingsStore from '$lib/stores/config-store';-import { get } from 'svelte/store';-type SkipCacheUntil = {[key: string]: number;};-export function getApplicationLogo(full = false): string {- const settings = get(settingsStore);- const accentColor = settings?.accentColor || 'default';-- // Add accent color as query param to bust cache when color changes+export function getApplicationLogo(full = false, colorOverride?: string): string {+ // Build base URL - don't include color param for normal requests+ // The backend reads the saved color from settings automatically+ // Only include color param when explicitly previewing a different colorconst baseUrl = full ? '/api/app-images/logo?full=true' : '/api/app-images/logo';- const separator = full ? '&' : '?';- const urlWithColor = `${baseUrl}${separator}color=${encodeURIComponent(accentColor)}`;- return getCachedImageUrl(urlWithColor);+ if (colorOverride) {+ const separator = full ? '&' : '?';+ return `${baseUrl}${separator}color=${encodeURIComponent(colorOverride)}`;+ }++ return getCachedImageUrl(baseUrl);}++export function bustLogoCache(): void {+ // Set skip cache for all logo URL patterns to force refetch+ const skipCacheUntil = Date.now() + 60000; // Skip cache for 1 minute+ const skipCacheUntilMap: SkipCacheUntil = JSON.parse(localStorage.getItem('skip-cache-until') ?? '{}');++ // Clear all existing logo cache entries and set new ones+ for (const key of Object.keys(skipCacheUntilMap)) {+ delete skipCacheUntilMap[key];+ }++ // Add cache bust timestamp for base logo URLs+ skipCacheUntilMap[hashKey('/api/app-images/logo')] = skipCacheUntil;+ skipCacheUntilMap[hashKey('/api/app-images/logo?full=true')] = skipCacheUntil;++ localStorage.setItem('skip-cache-until', JSON.stringify(skipCacheUntilMap));+}+export function getDefaultProfilePicture(): string {return getCachedImageUrl('/api/app-images/profile');}