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 existing updates sync (#172)
Hakan Shehufefcd296649e
diff --git a/apps/server/src/lib/documents.ts b/apps/server/src/lib/documents.tsindex ea663d35..89829e4a 100644--- a/apps/server/src/lib/documents.ts+++ b/apps/server/src/lib/documents.ts@@ -115,17 +115,17 @@ export const updateDocumentFromMutation = async (user: SelectUser,mutation: UpdateDocumentMutationData): Promise<MutationStatus> => {- const existingDocumentUpdate = await database- .selectFrom('document_updates')- .where('id', '=', mutation.updateId)- .selectAll()- .executeTakeFirst();-- if (existingDocumentUpdate) {- return MutationStatus.OK;- }-for (let count = 0; count < UPDATE_RETRIES_LIMIT; count++) {+ const existingDocumentUpdate = await database+ .selectFrom('document_updates')+ .where('id', '=', mutation.updateId)+ .selectAll()+ .executeTakeFirst();++ if (existingDocumentUpdate) {+ return MutationStatus.OK;+ }+const result = await tryUpdateDocumentFromMutation(user, mutation);if (result.type === 'success') {diff --git a/apps/server/src/lib/nodes.ts b/apps/server/src/lib/nodes.tsindex cba8dcf8..8d51228f 100644--- a/apps/server/src/lib/nodes.ts+++ b/apps/server/src/lib/nodes.ts@@ -481,17 +481,17 @@ export const updateNodeFromMutation = async (user: SelectUser,mutation: UpdateNodeMutationData): Promise<MutationStatus> => {- const existingNodeUpdate = await database- .selectFrom('node_updates')- .selectAll()- .where('id', '=', mutation.updateId)- .executeTakeFirst();+ for (let count = 0; count < UPDATE_RETRIES_LIMIT; count++) {+ const existingNodeUpdate = await database+ .selectFrom('node_updates')+ .selectAll()+ .where('id', '=', mutation.updateId)+ .executeTakeFirst();- if (existingNodeUpdate) {- return MutationStatus.OK;- }+ if (existingNodeUpdate) {+ return MutationStatus.OK;+ }- for (let count = 0; count < UPDATE_RETRIES_LIMIT; count++) {const result = await tryUpdateNodeFromMutation(user, mutation);if (result.type === 'success') {