From 04f3afea09e983b5c311ad1c120e5e40ffb5d6ef Mon Sep 17 00:00:00 2001 From: Will Anderson Date: Fri, 1 May 2026 23:51:13 -0500 Subject: [PATCH] account: fix duplicate billing line + always show badge for founding members MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Duplicate "Lifetime ยท Never billed again" was caused by insertAdjacentHTML('afterend') appending another

on every renderPlanCard call - and renderPlanCard runs both in init() and on the onAuthStateChange INITIAL_SESSION event, so the line stacks. Replaced with a dedicated #plan-billing-note-el container that setHtml() replaces in place. Badge: collapsed the two-branch fetch into one path. Founding members now always see the badge; if member_number is set we render "#N", otherwise we fall through to "Your number awaits" via the existing n=0 endpoint behaviour. --- src/account.el | 31 ++++++++----------------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/src/account.el b/src/account.el index 68dda18..909e6a1 100644 --- a/src/account.el +++ b/src/account.el @@ -718,6 +718,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String {

Loading...

+
@@ -1029,7 +1030,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String { } setHtml('plan-status-el', statusHtml); - // Billing note below status + // Billing note (replaces, never appends - this function may run more than once on auth state changes) var billingNote = ''; if (plan === 'founding') { billingNote = '

Lifetime · Never billed again

'; @@ -1038,8 +1039,7 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String { } else { billingNote = '

On the waitlist

'; } - var statusEl = document.getElementById('plan-status-el'); - if (statusEl) statusEl.insertAdjacentHTML('afterend', billingNote); + setHtml('plan-billing-note-el', billingNote); // Meta var meta = ''; @@ -1055,31 +1055,16 @@ fn account_page(supabase_url: String, supabase_anon_key: String) -> String { setHtml('plan-meta-el', meta); } - // Founding badge - if (plan === 'founding' && memberNum) { + // Founding badge - always show for founding members, with member number if assigned + if (plan === 'founding') { var badgeSection = document.getElementById('badge-section'); var badgeContainer = document.getElementById('badge-html-container'); - if (badgeSection && badgeContainer) { - badgeSection.style.display = ''; - // Fetch badge HTML from server - fetch('/api/founding-badge?n=' + memberNum) - .then(function(r) { return r.text(); }) - .then(function(html) { - badgeContainer.innerHTML = html; - }) - .catch(function(e) { - console.error('Failed to load badge:', e); - }); - } - } else if (plan === 'founding') { - // Founding member but number not yet assigned - var badgeSection = document.getElementById('badge-section'); if (badgeSection) badgeSection.style.display = ''; - fetch('/api/founding-badge?n=0') + var badgeN = memberNum || 0; + fetch('/api/founding-badge?n=' + badgeN) .then(function(r) { return r.text(); }) .then(function(html) { - var c = document.getElementById('badge-html-container'); - if (c) c.innerHTML = html; + if (badgeContainer) badgeContainer.innerHTML = html; }) .catch(function() {}); }