aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/nwc.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-08-14 01:19:44 -0700
committerAdam Soltys <[email protected]>2026-08-14 01:19:44 -0700
commit7a7b2c61fe8394844fa306debb84917454ade7b0 (patch)
tree4d2505c52dc239b5379e43400ac7bf822773e7aa /src/features/nwc.js
parent5b23470f5d9ec7ee7cc33c2b4b936ddd24fa17cc (diff)
downloadcoinosv3-7a7b2c61fe8394844fa306debb84917454ade7b0.tar.gz
coinosv3-7a7b2c61fe8394844fa306debb84917454ade7b0.zip
Settings grows a Notifications page — per-category switches the notifier honours server-side — and the status bar gets a real coinos badge instead of a black blob
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_014tE4U5nEjGTQy8PwYqamfv
Diffstat (limited to 'src/features/nwc.js')
-rw-r--r--src/features/nwc.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/features/nwc.js b/src/features/nwc.js
index d6bfdea..90ccb84 100644
--- a/src/features/nwc.js
+++ b/src/features/nwc.js
@@ -216,13 +216,14 @@ export function nwcFeature(ctx) {
// worker — surface it the same way. A visible tab already shows it live.
async function notifySent(c, amountSat, feeSat) {
try {
+ if (load().paySentNotify === false) return;
if (typeof document === 'undefined' || !document.hidden) return;
if (typeof Notification === 'undefined' || Notification.permission !== 'granted') return;
const reg = await navigator.serviceWorker.ready;
await reg.showNotification(t('nwcPaidTitle'), {
body: t('nwcPaidBody', { amount: amountSat.toLocaleString(), name: c.name || 'app' })
+ (feeSat ? ` (+${feeSat} fee)` : ''),
- icon: 'icon-192.png', badge: 'icon-192.png',
+ icon: 'icon-192.png', badge: 'badge-96.png',
tag: 'nwc-sent', renotify: true, data: { url: './' },
});
} catch {}
@@ -699,7 +700,8 @@ export function nwcFeature(ctx) {
bgTimer = setTimeout(async () => {
try {
if (!hook('arkBgReady')) return;
- await hook('arkBgWrite', conns(), load().offer || null);
+ await hook('arkBgWrite', conns(), load().offer || null,
+ { paySent: load().paySentNotify !== false });
} catch (e) { console.warn('nwc: could not write background state', e.message); }
}, 1500);
}
@@ -850,5 +852,15 @@ export function nwcFeature(ctx) {
init() { listen(); startWatchdog(); refreshRegistration(); reconcileBg(); ensureBackground(false); },
stop() { stop(); if (watchdog) { clearInterval(watchdog); watchdog = null; } },
nostrSettingsCards() { return [nwcCard()]; },
+ notifySettingsCards() {
+ const on = load().paySentNotify !== false;
+ return [h('div', { class: 'card col', style: 'gap:10px' },
+ h('div', { class: 'row between' },
+ h('span', { class: 'small' }, t('notifPaySent')),
+ h('button', { class: 'btn-sm', onClick: () => {
+ const s = load(); s.paySentNotify = !on; save(s); writeBg(); render();
+ } }, on ? t('nwcOn') : t('nwcOff'))),
+ h('div', { class: 'small faint' }, t('notifPaySentHint')))];
+ },
};
}