Refactor image URL handling: Update API routes to return image URLs via the API instead of direct paths, ensuring consistency across avatar and background uploads. Introduce normalization functions for avatar and background URLs to maintain compatibility with existing URLs.
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 2m57s

This commit is contained in:
Julien Froidefond
2025-12-12 15:59:18 +01:00
parent 702476c349
commit f69fbbd0e1
11 changed files with 238 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import { useEffect, useState, useRef } from "react";
import { normalizeBackgroundUrl } from "@/lib/avatars";
interface Preferences {
homeBackground: string | null;
@@ -49,8 +50,10 @@ export function useBackgroundImage(
if (preferences) {
const imageKey = `${page}Background` as keyof Preferences;
const customImage = preferences[imageKey];
const targetImage = customImage || defaultImage;
const rawImage = customImage || defaultImage;
// Normaliser l'URL pour utiliser l'API si nécessaire
const targetImage = normalizeBackgroundUrl(rawImage) || defaultImage;
// Ne changer que si l'image est vraiment différente
if (targetImage !== prevImageRef.current) {
prevImageRef.current = targetImage;