mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-28 09:33:46 +00:00
Merge pull request #222 from BEDOLAGA-DEV/dev
fix: move cabinet_branding to sessionStorage and add WebGL availabili…
This commit is contained in:
@@ -46,25 +46,32 @@ export const isLogoPreloaded = (): boolean => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get cached branding from localStorage
|
// Get cached branding from sessionStorage
|
||||||
export const getCachedBranding = (): BrandingInfo | null => {
|
export const getCachedBranding = (): BrandingInfo | null => {
|
||||||
try {
|
try {
|
||||||
const cached = localStorage.getItem(BRANDING_CACHE_KEY);
|
const cached = sessionStorage.getItem(BRANDING_CACHE_KEY);
|
||||||
if (cached) {
|
if (cached) {
|
||||||
return JSON.parse(cached);
|
return JSON.parse(cached);
|
||||||
}
|
}
|
||||||
|
// One-time migration: move stale localStorage value to sessionStorage
|
||||||
|
const legacy = localStorage.getItem(BRANDING_CACHE_KEY);
|
||||||
|
if (legacy) {
|
||||||
|
localStorage.removeItem(BRANDING_CACHE_KEY);
|
||||||
|
sessionStorage.setItem(BRANDING_CACHE_KEY, legacy);
|
||||||
|
return JSON.parse(legacy);
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
// localStorage not available or invalid JSON
|
// storage not available or invalid JSON
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update branding cache in localStorage
|
// Update branding cache in sessionStorage
|
||||||
export const setCachedBranding = (branding: BrandingInfo) => {
|
export const setCachedBranding = (branding: BrandingInfo) => {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(BRANDING_CACHE_KEY, JSON.stringify(branding));
|
sessionStorage.setItem(BRANDING_CACHE_KEY, JSON.stringify(branding));
|
||||||
} catch {
|
} catch {
|
||||||
// localStorage not available
|
// sessionStorage not available
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ export function AppHeader({
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
initialData: getCachedBranding() ?? undefined,
|
initialData: getCachedBranding() ?? undefined,
|
||||||
|
initialDataUpdatedAt: 0,
|
||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
retry: 1,
|
retry: 1,
|
||||||
|
|||||||
@@ -127,7 +127,30 @@ function generateColorStops(background: string, surface: string, accent: string)
|
|||||||
return [background, surface, dimAccent(accent)];
|
return [background, surface, dimAccent(accent)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _webglAvailable: boolean | null = null;
|
||||||
|
|
||||||
|
function isWebglAvailable(): boolean {
|
||||||
|
if (_webglAvailable === null) {
|
||||||
|
try {
|
||||||
|
const renderer = new Renderer({
|
||||||
|
alpha: true,
|
||||||
|
antialias: false,
|
||||||
|
powerPreference: 'low-power',
|
||||||
|
});
|
||||||
|
_webglAvailable = !!renderer.gl;
|
||||||
|
} catch {
|
||||||
|
_webglAvailable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _webglAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
export function Aurora() {
|
export function Aurora() {
|
||||||
|
if (!isWebglAvailable()) return null;
|
||||||
|
return <AuroraImpl />;
|
||||||
|
}
|
||||||
|
|
||||||
|
function AuroraImpl() {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
const animationFrameRef = useRef<number>(0);
|
const animationFrameRef = useRef<number>(0);
|
||||||
const rendererRef = useRef<Renderer | null>(null);
|
const rendererRef = useRef<Renderer | null>(null);
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ export function DesktopSidebar({
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
initialData: getCachedBranding() ?? undefined,
|
initialData: getCachedBranding() ?? undefined,
|
||||||
|
initialDataUpdatedAt: 0,
|
||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
retry: 1,
|
retry: 1,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ export function useBranding() {
|
|||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
initialData: getCachedBranding() ?? undefined,
|
initialData: getCachedBranding() ?? undefined,
|
||||||
|
initialDataUpdatedAt: 0,
|
||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
enabled: isAuthenticated,
|
enabled: isAuthenticated,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ export default function Login() {
|
|||||||
},
|
},
|
||||||
staleTime: 60000,
|
staleTime: 60000,
|
||||||
initialData: cachedBranding ?? undefined,
|
initialData: cachedBranding ?? undefined,
|
||||||
|
initialDataUpdatedAt: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Check if email auth is enabled
|
// Check if email auth is enabled
|
||||||
|
|||||||
Reference in New Issue
Block a user