Enable offline delete and reconnect queue sync

This commit is contained in:
Matthias
2026-04-01 10:37:20 +02:00
parent da576c1400
commit b6187210c7
7 changed files with 441 additions and 77 deletions

View File

@@ -742,9 +742,18 @@ export const batchRemove = mutation({
const user = await requireAuth(ctx);
if (nodeIds.length === 0) return;
// Canvas-Zugriff über den ersten Node prüfen
const firstNode = await ctx.db.get(nodeIds[0]);
if (!firstNode) throw new Error("Node not found");
// Idempotent: wenn alle Nodes bereits weg sind, no-op.
const firstExistingNode = await (async () => {
for (const nodeId of nodeIds) {
const node = await ctx.db.get(nodeId);
if (node) return node;
}
return null;
})();
if (!firstExistingNode) return;
// Canvas-Zugriff über den ersten vorhandenen Node prüfen
const firstNode = firstExistingNode;
await getCanvasOrThrow(ctx, firstNode.canvasId, user.userId);
for (const nodeId of nodeIds) {