feat: enhance background image handling with cache-busting

- Added a cache-busting query parameter to the background image URL to ensure the browser reloads the image when updated.
- Updated the AppState to include an optional imageVersion property for managing image updates.
- Modified the BoardBackgroundModal and BoardView components to utilize the new imageVersion for dynamic image loading.
This commit is contained in:
Cody Seibert
2025-12-12 23:09:51 -05:00
parent b32af0c86b
commit 104f478f89
3 changed files with 19 additions and 3 deletions

View File

@@ -90,14 +90,22 @@ export function BoardBackgroundModal({
if (currentProject && backgroundSettings.imagePath) {
const serverUrl =
process.env.NEXT_PUBLIC_SERVER_URL || "http://localhost:3008";
// Add cache-busting query parameter to force browser to reload image
const cacheBuster = backgroundSettings.imageVersion
? `&v=${backgroundSettings.imageVersion}`
: `&v=${Date.now()}`;
const imagePath = `${serverUrl}/api/fs/image?path=${encodeURIComponent(
backgroundSettings.imagePath
)}&projectPath=${encodeURIComponent(currentProject.path)}`;
)}&projectPath=${encodeURIComponent(currentProject.path)}${cacheBuster}`;
setPreviewImage(imagePath);
} else {
setPreviewImage(null);
}
}, [currentProject, backgroundSettings.imagePath]);
}, [
currentProject,
backgroundSettings.imagePath,
backgroundSettings.imageVersion,
]);
const fileToBase64 = (file: File): Promise<string> => {
return new Promise((resolve, reject) => {