Stop payout notices interrupting members who are earning

Marty hit this viewing daily ads: a popup after every single return to
the dashboard, each one a different payout notice.

Two causes, both fixed.

The channel was shared. "You just got paid 40.8923 POL" and "Welcome to
my line, here are your first three moves" were stored identically, as
kind 'broadcast' — the kind the sign-in modal is meant to interrupt for.
Dismissing one just promoted the next unread notice, so a backlog became
a carousel. System messages are now kind 'notice': they land in the
inbox, count toward its badge, and never pop. Only a message a person
actually wrote can interrupt.

The modal also had no memory. loadDashboard() runs on far more than
sign-in — after every ad view, campaign edit and chat close — and it
re-popped each time. It now shows at most once per page load and never
twice for the same message.

The 79 existing machine-generated rows are retagged by a migration in
ensureSchema, 15 of them unread and currently popping. Matched on
subject rather than sender on purpose: these come from member 1 at
ADMIN_EMAIL, which is also Marty's own member address, so his genuine
broadcasts sit under the same sender and must be left alone. Verified
against the live data first — "Credits returned: a counting error on our
side" and the broken-banner note are his, and stay as broadcasts.

qa/messages-notice.mjs covers it: a flood of 25 notices produces no
interruption, the human message still does, and chat stays in its own
lane. Member walk clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
martbost
2026-09-18 08:09:50 -05:00
parent a84b851272
commit a2c77d01d1
6 changed files with 113 additions and 13 deletions
+12 -1
View File
@@ -1290,8 +1290,18 @@
window.addEventListener('focus', () => { const p = $('vidPlayer'); if (p && p.src && !vidState.done) p.play().catch(() => {}); });
// ── unmissable sponsor-message modal on sign-in ──
// Only a message a PERSON wrote reaches here; system notices (payouts, purchase
// confirmations) are kind 'notice' and go straight to the inbox.
//
// loadDashboard() runs on far more than sign-in — it refreshes after every ad view, every
// campaign edit, every chat close. So the modal is shown at most once per page load and
// never twice for the same message, otherwise a member earning credits gets interrupted
// after every single view.
const msgModalShown = new Set();
function showSponsorModal(msg) {
if (!$('msgModal')) return;
if (!$('msgModal') || !msg || msgModalShown.has(msg.id)) return;
if (!$('msgModal').hidden) return; // one already open
msgModalShown.add(msg.id);
$('mmFrom').textContent = 'A message from ' + (msg.fromName || 'your sponsor');
$('mmSubject').textContent = msg.subject || '';
$('mmBody').innerHTML = msg.body || ''; // server-sanitized
@@ -1299,6 +1309,7 @@
$('mmAck').onclick = async () => {
$('msgModal').hidden = true;
try { await fetch('/api/my/messages/' + msg.id + '/read', { method: 'POST' }); } catch (e) {}
setInboxBadge(Math.max(0, (Number($('inboxBadge') && $('inboxBadge').textContent) || 1) - 1));
};
}
+1 -1
View File
@@ -1033,7 +1033,7 @@
<script src="/assets/common.js?v=20260916a"></script>
<script src="/assets/wallet.js?v=20260911a"></script>
<script src="/assets/promo.js?v=20260911a"></script>
<script src="/assets/my.js?v=20260916f"></script>
<script src="/assets/my.js?v=20260918a"></script>
<script src="/assets/chat.js?v=20260907l"></script>
</body>
</html>