Skip to content

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

Delete local mutation after some retries

Hakan Shehu084340519543
diff --git a/desktop/src/electron/workspace-manager.ts b/desktop/src/electron/workspace-manager.ts
index ee660fec..594213f6 100644
--- a/desktop/src/electron/workspace-manager.ts
+++ b/desktop/src/electron/workspace-manager.ts
@@ -220,13 +220,26 @@ export class WorkspaceManager {
return;
}
- const executedMutations = data.results
+ const executedMutationIds = data.results
.filter((result) => result.status === 'success')
.map((result) => result.id);
+ const mutliFailureMutationIds = mutations
+ .filter(
+ (mutation) =>
+ mutation.retry_count >= 5 &&
+ !executedMutationIds.includes(mutation.id),
+ )
+ .map((mutation) => mutation.id);
+
+ const toDeleteMutationIds = [
+ ...executedMutationIds,
+ ...mutliFailureMutationIds,
+ ];
+
await this.database
.deleteFrom('mutations')
- .where('id', 'in', executedMutations)
+ .where('id', 'in', toDeleteMutationIds)
.execute();
const failedMutationIds = data.results