Fix batch info in footer: include batchCurrent/batchTotal in per-relay progress events, set currentBatch before each batch starts

This commit is contained in:
Laan Tungir
2026-06-30 10:55:04 -04:00
parent 978e5029f3
commit 9b746838c3
2 changed files with 13 additions and 5 deletions

View File

@@ -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"
}

View File

@@ -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) {