deploy: bound indeedhub fixups and polish bitcoin ui

This commit is contained in:
archipelago
2026-06-11 02:32:10 -04:00
parent 84b283f5b6
commit 10e4f218a6
3 changed files with 52 additions and 31 deletions

View File

@@ -779,6 +779,18 @@
if (el) el.textContent = value || fallback;
}
function setTextIfPresent(id, value) {
const el = document.getElementById(id);
if (el) el.textContent = value;
return el;
}
function setWidthIfPresent(id, value) {
const el = document.getElementById(id);
if (el) el.style.width = value;
return el;
}
function renderRelayRequests(requests = []) {
const list = document.getElementById('relayRequestsList');
if (!list) return;
@@ -1115,7 +1127,9 @@
const rpcEl = document.getElementById('settingsRpc');
if (rpcEl) {
const port = chain === 'main' ? 8332 : (chain === 'test' ? 18332 : (chain === 'signet' ? 38332 : 18443));
rpcEl.textContent = status.stale
const statusAgeMs = status.updated_at_ms ? Date.now() - status.updated_at_ms : Number.POSITIVE_INFINITY;
const displayStale = status.stale === true && statusAgeMs > 30000;
rpcEl.textContent = displayStale
? `Reconnecting on port ${port}`
: `Reachable on port ${port}`;
}
@@ -1128,6 +1142,10 @@
const isSynced = headers > 0 && blocks >= headers - 1 && !initialBlockDownload;
const diskSize = formatBytes(blockchainInfo.size_on_disk || 0);
const appearsToBeReindexing = initialBlockDownload && blocks === 0 && headers > 0 && (blockchainInfo.size_on_disk || 0) > 1024 * 1024 * 1024;
const previousBlockCount = lastBlockCount;
const statusAgeMs = status.updated_at_ms ? Date.now() - status.updated_at_ms : Number.POSITIVE_INFINITY;
const snapshotAdvanced = previousBlockCount > 0 && blocks > previousBlockCount;
const displayStale = status.stale === true && !snapshotAdvanced && statusAgeMs > 30000;
// Calculate actual sync percentage based on blocks/headers
const actualSyncValue = headers > 0 ? (blocks / headers) * 100 : 0;
@@ -1137,21 +1155,21 @@
// Animate block count if it changed
const currentHeightElem = document.getElementById('currentHeight');
if (blocks !== lastBlockCount && lastBlockCount > 0) {
if (currentHeightElem && blocks !== lastBlockCount && lastBlockCount > 0) {
currentHeightElem.classList.add('number-update');
setTimeout(() => currentHeightElem.classList.remove('number-update'), 500);
}
lastBlockCount = blocks;
currentHeightElem.textContent = blocks.toLocaleString();
document.getElementById('networkHeight').textContent = headers.toLocaleString();
document.getElementById('headers').textContent = headers.toLocaleString();
document.getElementById('verificationProgress').textContent = `${verificationPercentage}%`;
document.getElementById('syncPercentage').textContent = `${actualSyncPercentage}%`;
document.getElementById('currentBlock').textContent = appearsToBeReindexing
setTextIfPresent('currentHeight', blocks.toLocaleString());
setTextIfPresent('networkHeight', headers.toLocaleString());
setTextIfPresent('headers', headers.toLocaleString());
setTextIfPresent('verificationProgress', `${verificationPercentage}%`);
setTextIfPresent('syncPercentage', `${actualSyncPercentage}%`);
setTextIfPresent('currentBlock', appearsToBeReindexing
? 'Reindexing from disk'
: `Block ${blocks.toLocaleString()}`;
document.getElementById('syncProgressBar').style.width = `${progressWidth}%`;
: `Block ${blocks.toLocaleString()}`);
setWidthIfPresent('syncProgressBar', `${progressWidth}%`);
// Update sync status text and icon
const syncStatusText = document.getElementById('syncStatusText');
@@ -1165,10 +1183,10 @@
syncIcon.classList.remove('text-green-500');
}
} else if (isSynced) {
syncStatusText.textContent = status.stale
syncStatusText.textContent = displayStale
? 'Bitcoin node is reconnecting... showing last known synchronized state'
: '✓ Fully synchronized with the network';
syncStatusText.className = status.stale ? 'text-yellow-300 text-sm font-medium' : 'text-green-400 text-sm font-medium';
syncStatusText.className = displayStale ? 'text-yellow-300 text-sm font-medium' : 'text-green-400 text-sm font-medium';
// Stop spinning when synced
if (syncIcon) {
syncIcon.classList.remove('animate-spin-slow');
@@ -1176,12 +1194,12 @@
}
} else {
const remaining = headers - blocks;
syncStatusText.textContent = status.stale
syncStatusText.textContent = displayStale
? 'Bitcoin node is reconnecting... showing last known sync state'
: initialBlockDownload
? `Initial block download... ${remaining.toLocaleString()} blocks remaining`
: `Syncing... ${remaining.toLocaleString()} blocks remaining`;
syncStatusText.className = status.stale ? 'text-yellow-300 text-sm font-medium' : 'text-orange-400 text-sm font-medium';
syncStatusText.className = displayStale ? 'text-yellow-300 text-sm font-medium' : 'text-orange-400 text-sm font-medium';
// Keep spinning while syncing
if (syncIcon) {
syncIcon.classList.add('animate-spin-slow');