Open-source and local-first Slack and Notion alternative that puts you in control of your data
TypeScript chatchat-applicationcrdteditorelectronknowledge-baselocal-firstnotionnotion-alternativerealtime-collaborationself-hostedslacksqliteteam-collaborationwikiyjs
Improve replace transactions service
Hakan Shehu8632a3d8ec14
diff --git a/apps/desktop/src/main/services/node-service.ts b/apps/desktop/src/main/services/node-service.tsindex 0c809b12..83c9b139 100644--- a/apps/desktop/src/main/services/node-service.ts+++ b/apps/desktop/src/main/services/node-service.ts@@ -586,13 +586,18 @@ class NodeService {public async replaceTransactions(userId: string,nodeId: string,- transactions: ServerTransaction[]+ transactions: ServerTransaction[],+ transactionCursor: bigint): Promise<boolean> {const workspaceDatabase =await databaseService.getWorkspaceDatabase(userId);const firstTransaction = transactions[0];- if (!firstTransaction) {+ if (!firstTransaction || firstTransaction.operation !== 'create') {+ return false;+ }++ if (transactionCursor < BigInt(firstTransaction.version)) {return false;}diff --git a/apps/desktop/src/main/services/sync-service.ts b/apps/desktop/src/main/services/sync-service.tsindex 282e66dc..8d1ac721 100644--- a/apps/desktop/src/main/services/sync-service.ts+++ b/apps/desktop/src/main/services/sync-service.ts@@ -439,10 +439,12 @@ class SyncService {continue;}+ const cursor = await this.fetchCursor(userId, 'transactions');const synced = await nodeService.replaceTransactions(userId,nodeId,- data.transactions+ data.transactions,+ cursor);if (!synced) {@@ -558,10 +560,12 @@ class SyncService {});+ const cursor = await this.fetchCursor(userId, 'transactions');await nodeService.replaceTransactions(userId,node.node_id,- data.transactions+ data.transactions,+ cursor);} catch (error) {this.debug(@@ -626,10 +630,12 @@ class SyncService {});+ const cursor = await this.fetchCursor(event.userId, 'transactions');await nodeService.replaceTransactions(event.userId,event.nodeId,- data.transactions+ data.transactions,+ cursor);} catch (error) {this.debug(