zaps: make the card + modal zap counter always visible (0 sats when none)

Diagnosis (live, verified): the zap-totals pipeline is correct end to end —
a seeded receipt queries and sums to the right sats — but of 310 kind-9735
receipts reachable on the relays, ZERO reference any bitvid video, so every
badge was legitimately hidden. That reads as "broken" and profile zaps to a
Lightning address never attach to a video, so hidden-when-zero left the
feature invisible in practice.

Show the counter always, like the view counter it sits beside: "0 sats"
until a receipt lands, then the summed total. Card binder and modal render
no longer gate on sats>0; the badge is revealed on bind/open and re-hidden
on modal close (no video open). Live-checked: 158/158 cards render the
badge. Tests spec-corrected with integrity notes.

Co-Authored-By: Claude Fable 5 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Fable 5 committed 2026-07-04 14:43:22 -04:00
1 parent 213cb97ee8
commit 8d45f25962
4 files changed
+38 -32

No files matched your search

+6 -7
View File
@@ -81,17 +81,16 @@ export function createModalCoordinator(deps) {
if (!el || !pointer) {
return;
}
// Always visible while a video is open (mirrors the view counter); a zero
// is a real value, not noise to hide.
const render = () => {
const sats = getVideoZapTotalSnapshot(pointer);
const value = Number.isFinite(sats) && sats > 0 ? sats : 0;
const text = el.querySelector("[data-zap-total-text]");
if (Number.isFinite(sats) && sats > 0) {
if (text) {
text.textContent = `${formatViewCount(sats)} sats`;
}
el.classList.remove("hidden");
} else {
el.classList.add("hidden");
if (text) {
text.textContent = `${formatViewCount(value)} sats`;
}
el.classList.remove("hidden");
};
requestVideoZapTotal(pointer);
render();
+7 -7
View File
@@ -23,15 +23,15 @@ export function createZapTotalBinder({ formatSats = defaultFormatSats } = {}) {
const entries = new Map(); // pointerKey → { pointer, elements:Set }
let unsubscribe = null;
// Always visible, mirroring the view counter (a zero is a real, informative
// value — "this hasn't been zapped yet" — not noise to hide). The wrapper
// starts hidden in markup and is revealed on first bind so cards without a
// pointer stay clean.
const renderElement = (el, sats) => {
const wrapper = el.closest?.(".video-card__zaps") || null;
if (Number.isFinite(sats) && sats > 0) {
el.textContent = formatSats(sats);
wrapper?.classList?.remove("hidden");
} else {
el.textContent = "";
wrapper?.classList?.add("hidden");
}
const value = Number.isFinite(sats) && sats > 0 ? sats : 0;
el.textContent = formatSats(value);
wrapper?.classList?.remove("hidden");
};
const renderKey = (key) => {