fix: check window existence before opening db

Prevent runtime errors by ensuring window is defined before attempting to open IndexedDB
This commit is contained in:
KevIsDev 2025-06-20 15:34:26 +01:00
parent 75acdc9afb
commit 90fecdb565

View File

@ -34,7 +34,7 @@ export interface ChatHistoryItem {
const persistenceEnabled = !import.meta.env.VITE_DISABLE_PERSISTENCE;
export const db = persistenceEnabled ? await openDatabase() : undefined;
export const db = typeof window !== 'undefined' && persistenceEnabled ? await openDatabase() : undefined;
export const chatId = atom<string | undefined>(undefined);
export const description = atom<string | undefined>(undefined);