mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 13:01:59 +03:00
refactor(electron): always save one update to electron (#7009)
not sure do we still need this one
This commit is contained in:
parent
f50e240e3d
commit
fdc33bd3ec
@ -7,7 +7,7 @@ import { getWorkspaceMeta } from '../workspace/meta';
|
||||
import { SQLiteAdapter } from './db-adapter';
|
||||
import { mergeUpdate } from './merge-update';
|
||||
|
||||
const TRIM_SIZE = 500;
|
||||
const TRIM_SIZE = 1;
|
||||
|
||||
export class WorkspaceSQLiteDB {
|
||||
lock = new AsyncLock();
|
||||
@ -87,12 +87,16 @@ export class WorkspaceSQLiteDB {
|
||||
|
||||
async addUpdateToSQLite(update: Uint8Array, subdocId: string) {
|
||||
this.update$.next();
|
||||
await this.adapter.addUpdateToSQLite([
|
||||
{
|
||||
data: update,
|
||||
docId: this.toDBDocId(subdocId),
|
||||
},
|
||||
]);
|
||||
await this.transaction(async () => {
|
||||
const dbID = this.toDBDocId(subdocId);
|
||||
const oldUpdate = await this.adapter.getUpdates(dbID);
|
||||
await this.adapter.replaceUpdates(dbID, [
|
||||
{
|
||||
data: mergeUpdate([...oldUpdate.map(u => u.data), update]),
|
||||
docId: dbID,
|
||||
},
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
async deleteUpdate(subdocId: string) {
|
||||
|
Loading…
Reference in New Issue
Block a user