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