Sharding rows due to SQLite limits

This commit is contained in:
Marcel Mraz 2024-12-30 13:44:53 +01:00
parent 12be5d716b
commit f6061f5ec6
No known key found for this signature in database
GPG key ID: 4EBD6E62DC830CD2
7 changed files with 228 additions and 194 deletions

View file

@ -697,7 +697,7 @@ const ExcalidrawWrapper = () => {
// CFDO: some appState like selections should also be transfered (we could even persist it)
if (!elementsChange.isEmpty()) {
try {
syncAPI?.push("durable", increment);
syncAPI?.push(increment);
} catch (e) {
console.error(e);
}

View file

@ -108,12 +108,12 @@ export class LocalData {
files: BinaryFiles,
onFilesSaved: () => void,
) => {
saveDataStateToLocalStorage(elements, appState);
await this.fileStorage.saveFiles({
elements,
files,
});
onFilesSaved();
// saveDataStateToLocalStorage(elements, appState);
// await this.fileStorage.saveFiles({
// elements,
// files,
// });
// onFilesSaved();
},
SAVE_TO_LOCAL_STORAGE_TIMEOUT,
);
@ -260,13 +260,11 @@ export class LibraryLocalStorageMigrationAdapter {
}
}
interface SyncIncrementPersistedData {
increments: DTO<StoreIncrement>[];
}
type SyncIncrementPersistedData = DTO<StoreIncrement>[];
interface SyncMetaPersistedData {
type SyncMetaPersistedData = {
lastAcknowledgedVersion: number;
}
};
export class SyncIndexedDBAdapter {
/** IndexedDB database and store name */
@ -281,17 +279,15 @@ export class SyncIndexedDBAdapter {
);
static async loadIncrements() {
const IDBData = await get<SyncIncrementPersistedData>(
const increments = await get<SyncIncrementPersistedData>(
SyncIndexedDBAdapter.incrementsKey,
SyncIndexedDBAdapter.store,
);
if (IDBData?.increments?.length) {
return {
increments: IDBData.increments.map((storeIncrementDTO) =>
StoreIncrement.restore(storeIncrementDTO),
),
};
if (increments?.length) {
return increments.map((storeIncrementDTO) =>
StoreIncrement.restore(storeIncrementDTO),
);
}
return null;
@ -306,12 +302,12 @@ export class SyncIndexedDBAdapter {
}
static async loadMetadata() {
const IDBData = await get<SyncMetaPersistedData>(
const metadata = await get<SyncMetaPersistedData>(
SyncIndexedDBAdapter.metadataKey,
SyncIndexedDBAdapter.store,
);
return IDBData || null;
return metadata || null;
}
static async saveMetadata(data: SyncMetaPersistedData): Promise<void> {