Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Handle some cases in query check for changes events

Hakan Shehud6fa1cead365
diff --git a/apps/desktop/src/main/queries/node-get.ts b/apps/desktop/src/main/queries/node-get.ts
index 4594dfef..a7a46826 100644
--- a/apps/desktop/src/main/queries/node-get.ts
+++ b/apps/desktop/src/main/queries/node-get.ts
@@ -27,6 +27,17 @@ export class NodeGetQueryHandler implements QueryHandler<NodeGetQueryInput> {
};
}
+ if (
+ event.type === 'node_created' &&
+ event.userId === input.userId &&
+ event.node.id === input.nodeId
+ ) {
+ return {
+ hasChanges: true,
+ result: event.node,
+ };
+ }
+
if (
event.type === 'node_updated' &&
event.userId === input.userId &&
diff --git a/apps/desktop/src/main/queries/node-tree-get.ts b/apps/desktop/src/main/queries/node-tree-get.ts
index 673f1a55..9d31c63e 100644
--- a/apps/desktop/src/main/queries/node-tree-get.ts
+++ b/apps/desktop/src/main/queries/node-tree-get.ts
@@ -30,6 +30,18 @@ export class NodeTreeGetQueryHandler
};
}
+ if (
+ event.type === 'node_created' &&
+ event.userId === input.userId &&
+ event.node.id === input.nodeId
+ ) {
+ const newResult = await this.handleQuery(input);
+ return {
+ hasChanges: true,
+ result: newResult,
+ };
+ }
+
if (event.type === 'node_updated' && event.userId === input.userId) {
const node = output.find((node) => node.id === event.node.id);
if (node) {