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:
@@ -247,7 +247,7 @@ window.IAP = (function () {
|
||||
: '<input id="dlgInput" type="' + (o.type === 'number' ? 'number' : 'text') + '" ' + (o.type === 'number' ? 'inputmode="decimal" min="0" step="any" ' : '') + 'value="' + esc(o.value) + '" placeholder="' + esc(o.placeholder) + '" style="width:100%;margin-top:12px" autocomplete="off">';
|
||||
back.innerHTML = '<div class="modal-card" role="dialog" aria-modal="true">' + (o.title ? '<h3 style="margin:0 0 8px">' + esc(o.title) + '</h3>' : '')
|
||||
+ (o.text ? '<p class="muted small" style="margin:0;white-space:pre-line">' + esc(o.text) + '</p>' : '') + field
|
||||
+ '<div style="display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap"><button type="button" class="btn sec small" id="dlgCancel">' + esc(o.cancel || 'Cancel') + '</button><button type="button" class="btn small" id="dlgOk">' + esc(o.ok || 'OK') + '</button></div></div>';
|
||||
+ '<div style="display:flex;gap:10px;justify-content:flex-end;margin-top:16px;flex-wrap:wrap">' + (o.noCancel ? '' : '<button type="button" class="btn sec small" id="dlgCancel">' + esc(o.cancel || 'Cancel') + '</button>') + '<button type="button" class="btn small" id="dlgOk">' + esc(o.ok || 'OK') + '</button></div></div>';
|
||||
document.body.appendChild(back);
|
||||
const inp = back.querySelector('#dlgInput');
|
||||
const done = v => { document.removeEventListener('keydown', onKey); back.remove(); resolve(v); };
|
||||
@@ -255,7 +255,7 @@ window.IAP = (function () {
|
||||
const onKey = e => { if (e.key === 'Escape') { e.preventDefault(); done(o.type === 'none' ? false : null); } else if (e.key === 'Enter' && o.type !== 'textarea') { e.preventDefault(); okv(); } };
|
||||
document.addEventListener('keydown', onKey);
|
||||
back.querySelector('#dlgOk').addEventListener('click', okv);
|
||||
back.querySelector('#dlgCancel').addEventListener('click', () => done(o.type === 'none' ? false : null));
|
||||
if (back.querySelector('#dlgCancel')) back.querySelector('#dlgCancel').addEventListener('click', () => done(o.type === 'none' ? false : null));
|
||||
back.addEventListener('click', e => { if (e.target === back) done(o.type === 'none' ? false : null); });
|
||||
setTimeout(() => { if (inp) { inp.focus(); if (inp.select && o.type !== 'textarea') inp.select(); } else back.querySelector('#dlgOk').focus(); }, 30);
|
||||
});
|
||||
|
||||
+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