This commit is contained in:
@@ -158,19 +158,19 @@ export function PatternBackgroundProvider({ children }: { children: ReactNode })
|
||||
cached.patternDataUrl;
|
||||
|
||||
if (cacheHit) {
|
||||
// Serve cached pattern immediately, then revalidate in background.
|
||||
setPatternImageUrl(cached.patternDataUrl!);
|
||||
setThemeCache(restaurantSlug, {
|
||||
...themeBase,
|
||||
patternDataUrl: cached.patternDataUrl,
|
||||
});
|
||||
applyCachedThemeToDom(cached);
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
const proxyUrl = `/${restaurantSlug}/api/proxy-svg?url=${encodeURIComponent(themeBase.bgUrl)}`;
|
||||
|
||||
fetch(proxyUrl)
|
||||
fetch(proxyUrl, { cache: "no-store" })
|
||||
.then((response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error("Failed to fetch background pattern");
|
||||
@@ -181,7 +181,9 @@ export function PatternBackgroundProvider({ children }: { children: ReactNode })
|
||||
if (cancelled) return;
|
||||
|
||||
const dataUrl = svgToDataUrl(colorizeSvg(svg, menuColor));
|
||||
setPatternImageUrl(dataUrl);
|
||||
if (dataUrl !== cached?.patternDataUrl) {
|
||||
setPatternImageUrl(dataUrl);
|
||||
}
|
||||
|
||||
const nextCache = {
|
||||
...themeBase,
|
||||
|
||||
Reference in New Issue
Block a user