mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-23 16:22:21 +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 { SQLiteAdapter } from './db-adapter';
|
||||||
import { mergeUpdate } from './merge-update';
|
import { mergeUpdate } from './merge-update';
|
||||||
|
|
||||||
const TRIM_SIZE = 500;
|
const TRIM_SIZE = 1;
|
||||||
|
|
||||||
export class WorkspaceSQLiteDB {
|
export class WorkspaceSQLiteDB {
|
||||||
lock = new AsyncLock();
|
lock = new AsyncLock();
|
||||||
@ -87,12 +87,16 @@ export class WorkspaceSQLiteDB {
|
|||||||
|
|
||||||
async addUpdateToSQLite(update: Uint8Array, subdocId: string) {
|
async addUpdateToSQLite(update: Uint8Array, subdocId: string) {
|
||||||
this.update$.next();
|
this.update$.next();
|
||||||
await this.adapter.addUpdateToSQLite([
|
await this.transaction(async () => {
|
||||||
|
const dbID = this.toDBDocId(subdocId);
|
||||||
|
const oldUpdate = await this.adapter.getUpdates(dbID);
|
||||||
|
await this.adapter.replaceUpdates(dbID, [
|
||||||
{
|
{
|
||||||
data: update,
|
data: mergeUpdate([...oldUpdate.map(u => u.data), update]),
|
||||||
docId: this.toDBDocId(subdocId),
|
docId: dbID,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteUpdate(subdocId: string) {
|
async deleteUpdate(subdocId: string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user