Enhance canvas functionality by adding media preview capabilities and image upload handling. Introduce compressed image previews during uploads, improve media library integration, and implement retry logic for bridge edge creation. Update dashboard to display media previews and optimize image node handling.

This commit is contained in:
Matthias
2026-04-08 20:44:31 +02:00
parent a7eb2bc99c
commit b7f24223f2
43 changed files with 4064 additions and 148 deletions

View File

@@ -1,6 +1,8 @@
const STORAGE_NAMESPACE = "lemonspace.dashboard";
const CACHE_VERSION = 1;
const DEFAULT_TTL_MS = 12 * 60 * 60 * 1000;
const LAST_DASHBOARD_USER_KEY = "ls-last-dashboard-user";
const INVALIDATION_SIGNAL_KEY = `${STORAGE_NAMESPACE}:snapshot:invalidate:v${CACHE_VERSION}`;
type JsonRecord = Record<string, unknown>;
@@ -19,6 +21,15 @@ function getLocalStorage(): Storage | null {
}
}
function getSessionStorage(): Storage | null {
if (typeof window === "undefined") return null;
try {
return window.sessionStorage;
} catch {
return null;
}
}
function isRecord(value: unknown): value is JsonRecord {
return typeof value === "object" && value !== null;
}
@@ -120,3 +131,22 @@ export function clearDashboardSnapshotCache(userId: string): void {
if (!storage) return;
safeRemove(storage, cacheKey(userId));
}
export function invalidateDashboardSnapshotForLastSignedInUser(): void {
const sessionStorage = getSessionStorage();
if (!sessionStorage) return;
const userId = safeGet(sessionStorage, LAST_DASHBOARD_USER_KEY);
if (!userId) return;
clearDashboardSnapshotCache(userId);
}
export function emitDashboardSnapshotCacheInvalidationSignal(): void {
const storage = getLocalStorage();
if (!storage) return;
safeSet(storage, INVALIDATION_SIGNAL_KEY, String(Date.now()));
}
export function getDashboardSnapshotCacheInvalidationSignalKey(): string {
return INVALIDATION_SIGNAL_KEY;
}