From 9b746838c3270fbaa6f87b0329f03e897ee4e4d3 Mon Sep 17 00:00:00 2001 From: Laan Tungir Date: Tue, 30 Jun 2026 10:55:04 -0400 Subject: [PATCH] Fix batch info in footer: include batchCurrent/batchTotal in per-relay progress events, set currentBatch before each batch starts --- www/js/version.json | 6 +++--- www/ndk-worker.js | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/www/js/version.json b/www/js/version.json index 8c4d424..452df18 100644 --- a/www/js/version.json +++ b/www/js/version.json @@ -1,5 +1,5 @@ { - "VERSION": "v0.7.80", - "VERSION_NUMBER": "0.7.80", - "BUILD_DATE": "2026-06-30T14:42:12.863Z" + "VERSION": "v0.7.81", + "VERSION_NUMBER": "0.7.81", + "BUILD_DATE": "2026-06-30T14:55:04.841Z" } diff --git a/www/ndk-worker.js b/www/ndk-worker.js index a846390..5a994f3 100644 --- a/www/ndk-worker.js +++ b/www/ndk-worker.js @@ -6210,8 +6210,11 @@ async function handlePublish(requestId, event, port) { const publishSessionId = `pub_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`; const publishedSoFar = new Set(); const failedSoFar = new Set(); // explicit rejections (auth-required, blocked, etc.) - const timedOutSoFar = new Set(); // timeouts — NOT skip-marked (could be slow connect) + const timedOutSoFar = new Set(); // timeouts const totalTarget = isBroadcast ? allBroadcastUrls.length : 0; + // Track current batch for progress display. Updated by the batch loop. + let currentBatch = 0; + let totalBatches = 0; if (isBroadcast && totalTarget > 0) { console.log(`[Worker] Broadcasting to ${allBroadcastUrls.length} relays ` + @@ -6243,6 +6246,8 @@ async function handlePublish(requestId, event, port) { successful: publishedSoFar.size, failed: failedSoFar.size + timedOutSoFar.size, latestRelay: url, + batchCurrent: currentBatch, + batchTotal: totalBatches, }); }); @@ -6265,6 +6270,8 @@ async function handlePublish(requestId, event, port) { failed: failedSoFar.size + timedOutSoFar.size, latestRelay: url, latestError: errMsg, + batchCurrent: currentBatch, + batchTotal: totalBatches, }); }); } @@ -6322,7 +6329,7 @@ async function handlePublish(requestId, event, port) { for (let i = 0; i < broadcastOnlyUrls.length; i += BATCH_SIZE) { batches.push(broadcastOnlyUrls.slice(i, i + BATCH_SIZE)); } - const totalBatches = batches.length; + totalBatches = batches.length; console.log(`[Worker] Phase 2: Broadcasting to ${broadcastOnlyUrls.length} relays in ${totalBatches} batches of ${BATCH_SIZE}`); // Emit a progress event showing batch info before starting batches. @@ -6339,6 +6346,7 @@ async function handlePublish(requestId, event, port) { }); for (let bi = 0; bi < batches.length; bi++) { + currentBatch = bi + 1; // update before publish so per-relay events include it const batch = batches[bi]; const batchSet = NDKRelaySet.fromRelayUrls(batch, ndk); if (batchSet?.relays) {