Fix invite link params being cleared before handleInviteLink reads them

This commit is contained in:
Sterling Archer committed 2026-06-18 19:33:01 -07:00
1 parent 7403bb1d93
commit 645fe2d62b
1 file changed
+9 -5
+9 -5
View File
@@ -1517,6 +1517,10 @@ const APP_URL = window.location.origin + window.location.pathname.replace(/\/$/,
const STEP_GOAL = 5000; const STEP_GOAL = 5000;
const _initialParams = new URLSearchParams(window.location.search);
const _savedInviteToken = _initialParams.get('invite');
const _savedFromUid = _initialParams.get('from');
// ───────────────────────────────────────────── // ─────────────────────────────────────────────
// INIT // INIT
// ───────────────────────────────────────────── // ─────────────────────────────────────────────
@@ -1563,7 +1567,9 @@ window.sendMagicLink = async function() {
document.getElementById('magic-sent-card').style.display = 'block'; document.getElementById('magic-sent-card').style.display = 'block';
document.getElementById('magic-sent-email').textContent = email; document.getElementById('magic-sent-email').textContent = email;
} catch(e) { } catch(e) {
errEl.textContent = e.message || 'Failed to send link. Try again.'; errEl.textContent = e.message.includes('429') || e.message.includes('Too many')
? 'Too many requests — please wait a few minutes and try again.'
: (e.message || 'Failed to send link. Try again.');
errEl.style.display = 'block'; errEl.style.display = 'block';
btn.disabled = false; btn.disabled = false;
btn.innerHTML = 'Continue with Email'; btn.innerHTML = 'Continue with Email';
@@ -2411,11 +2417,9 @@ window.saveProfile = async function() {
// INVITE LINK HANDLER // INVITE LINK HANDLER
// ───────────────────────────────────────────── // ─────────────────────────────────────────────
async function handleInviteLink() { async function handleInviteLink() {
const params = new URLSearchParams(window.location.search); const inviteToken = _savedInviteToken;
const inviteToken = params.get('invite'); const fromUid = _savedFromUid;
const fromUid = params.get('from');
if (!inviteToken || !fromUid || fromUid === currentUser.uid) return; if (!inviteToken || !fromUid || fromUid === currentUser.uid) return;
window.history.replaceState({}, document.title, APP_URL);
try { try {
const inviteRef = doc(db, 'invites', inviteToken); const inviteRef = doc(db, 'invites', inviteToken);
const inviteSnap = await getDoc(inviteRef); const inviteSnap = await getDoc(inviteRef);