fix: use idb for elements and app state

This commit is contained in:
Ryan Di
2025-07-31 18:21:56 +10:00
parent 37ad85cbaf
commit cff7516318
4 changed files with 238 additions and 30 deletions
+17 -5
View File
@@ -21,11 +21,23 @@ type StorageSizes = { scene: number; total: number };
const STORAGE_SIZE_TIMEOUT = 500;
const getStorageSizes = debounce((cb: (sizes: StorageSizes) => void) => {
cb({
scene: getElementsStorageSize(),
total: getTotalStorageSize(),
});
const getStorageSizes = debounce(async (cb: (sizes: StorageSizes) => void) => {
try {
const [scene, total] = await Promise.all([
getElementsStorageSize(),
getTotalStorageSize(),
]);
cb({
scene,
total,
});
} catch (error) {
console.error("Failed to get storage sizes:", error);
cb({
scene: 0,
total: 0,
});
}
}, STORAGE_SIZE_TIMEOUT);
type Props = {