Skip to content

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

Fix sync for deleted nodes

Hakan Shehucb5c45860b39
diff --git a/server/src/consumers/changes-subcriber.ts b/server/src/consumers/changes-subcriber.ts
index 43e6fadc..7390ee97 100644
--- a/server/src/consumers/changes-subcriber.ts
+++ b/server/src/consumers/changes-subcriber.ts
@@ -77,6 +77,26 @@ const handleEvent = async (event: string) => {
return;
}
+ if (data.type === 'node_delete') {
+ for (const nodeUserState of nodeUserStates) {
+ const deviceIds = userDevices.get(nodeUserState.user_id) ?? [];
+ for (const deviceId of deviceIds) {
+ const socketConnection = socketManager.getConnection(deviceId);
+ if (socketConnection === undefined) {
+ continue;
+ }
+
+ socketConnection.send({
+ type: 'server_node_delete',
+ id: data.nodeId,
+ workspaceId: data.workspaceId,
+ });
+ }
+ }
+
+ return;
+ }
+
const node = await database
.selectFrom('nodes')
.select([