Broadcasts: a pop-up when sent (how many members) and when not sent (why); an expired sign-in keeps the draft and offers Sign in again (Brian 2026-10-05)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+21
-6
@@ -2034,12 +2034,27 @@
|
||||
const u = await IAP.ask({ title: 'Insert link', text: 'Link URL (https://…)', placeholder: 'https://', ok: 'Insert' });
|
||||
if (u) { $('bcEd').focus(); if (range) { sel.removeAllRanges(); sel.addRange(range); } document.execCommand('createLink', false, u); }
|
||||
});
|
||||
if ($('bcSendBtn')) $('bcSendBtn').addEventListener('click', busy2($('bcSendBtn'), async () => {
|
||||
const r = await api('/api/my/broadcast', { scope: $('bcScope').value, subject: $('bcSubject').value, body: $('bcEd').innerHTML });
|
||||
IAP.status('Broadcast sent to ' + r.sent + ' member' + (r.sent === 1 ? '' : 's') + '.', 'ok');
|
||||
$('bcSubject').value = ''; $('bcEd').innerHTML = '';
|
||||
$('bcHint').textContent = 'Sent. You can send your next broadcast in 24 hours.';
|
||||
}));
|
||||
// broadcast send (2026-10-05, Brian: "clicking send didn't give me anything to feel it was sent"): a pop-up either way,
|
||||
// and an expired sign-in keeps the draft so nothing typed is lost
|
||||
const BC_DRAFT = 'iap.bcDraft';
|
||||
try { const d = JSON.parse(localStorage.getItem(BC_DRAFT) || 'null'); if (d && $('bcSubject') && !$('bcSubject').value) { $('bcSubject').value = d.subject || ''; $('bcEd').innerHTML = d.body || ''; if ($('bcScope') && d.scope) $('bcScope').value = d.scope; localStorage.removeItem(BC_DRAFT); } } catch (e) {}
|
||||
if ($('bcSendBtn')) $('bcSendBtn').addEventListener('click', async () => {
|
||||
const btn = $('bcSendBtn'); btn.disabled = true; const label = btn.textContent; btn.textContent = 'Sending…';
|
||||
try {
|
||||
const r = await api('/api/my/broadcast', { scope: $('bcScope').value, subject: $('bcSubject').value, body: $('bcEd').innerHTML });
|
||||
$('bcSubject').value = ''; $('bcEd').innerHTML = '';
|
||||
$('bcHint').textContent = 'Sent. You can send your next broadcast in 24 hours.';
|
||||
await IAP.confirmBox('Your broadcast was delivered to ' + r.sent + ' member' + (r.sent === 1 ? '' : 's') + ' in your line. They see it in their Messages, and get a copy by email. You can send your next broadcast in 24 hours.', { title: '✅ Broadcast sent', ok: 'Done', noCancel: true });
|
||||
} catch (e) {
|
||||
const msg = (e && e.message) || String(e);
|
||||
if (/sign in/i.test(msg)) {
|
||||
try { localStorage.setItem(BC_DRAFT, JSON.stringify({ subject: $('bcSubject').value, body: $('bcEd').innerHTML, scope: $('bcScope').value })); } catch (x) {}
|
||||
if (await IAP.confirmBox('Your sign-in expired, so the broadcast was NOT sent. Your message is saved: sign in again and it will be waiting for you here.', { title: 'Not sent yet', ok: 'Sign in again', cancel: 'Close' })) location.href = '/my#line';
|
||||
} else {
|
||||
await IAP.confirmBox(msg + ' Your message is still in the box.', { title: 'Broadcast not sent', ok: 'OK', noCancel: true });
|
||||
}
|
||||
} finally { btn.disabled = false; btn.textContent = label; }
|
||||
});
|
||||
|
||||
// ── solo-ads inbox: list, read view, dwell-gated read reward ──
|
||||
let ibTimer = null;
|
||||
|
||||
Reference in New Issue
Block a user