atagen

malice

public
Star0
Watch0
b39ecae834a0cd6670068d28a7b4afd0498f7964
2
ssh://brewery@pls.lobotomise.me:33/atagen/malice.git

Blame: web/src/lib/NotificationSettings.svelte

db4e552594cbatagen2026-10-26 04:43 UTC1
<script lang="ts">
db4e552594cbatagen2026-10-26 04:43 UTC2
  import { disableNotifications, enableNotifications, notificationPermission, notificationsEnabled } from './notifications';
db4e552594cbatagen2026-10-26 04:43 UTC3
db4e552594cbatagen2026-10-26 04:43 UTC4
  let busy = false;
db4e552594cbatagen2026-10-26 04:43 UTC5
db4e552594cbatagen2026-10-26 04:43 UTC6
  $: denied = $notificationPermission === 'denied';
db4e552594cbatagen2026-10-26 04:43 UTC7
  $: unsupported = $notificationPermission === 'unsupported';
db4e552594cbatagen2026-10-26 04:43 UTC8
  $: on = $notificationsEnabled && $notificationPermission === 'granted';
db4e552594cbatagen2026-10-26 04:43 UTC9
db4e552594cbatagen2026-10-26 04:43 UTC10
  async function toggle(): Promise<void> {
db4e552594cbatagen2026-10-26 04:43 UTC11
    if (busy) return;
db4e552594cbatagen2026-10-26 04:43 UTC12
    busy = true;
db4e552594cbatagen2026-10-26 04:43 UTC13
    try {
db4e552594cbatagen2026-10-26 04:43 UTC14
      if (on) disableNotifications();
db4e552594cbatagen2026-10-26 04:43 UTC15
      else await enableNotifications();
db4e552594cbatagen2026-10-26 04:43 UTC16
    } finally {
db4e552594cbatagen2026-10-26 04:43 UTC17
      busy = false;
db4e552594cbatagen2026-10-26 04:43 UTC18
    }
db4e552594cbatagen2026-10-26 04:43 UTC19
  }
db4e552594cbatagen2026-10-26 04:43 UTC20
</script>
db4e552594cbatagen2026-10-26 04:43 UTC21
db4e552594cbatagen2026-10-26 04:43 UTC22
<section aria-label="Notifications">
db4e552594cbatagen2026-10-26 04:43 UTC23
  <div class="sec-head">
db4e552594cbatagen2026-10-26 04:43 UTC24
    <h3 class="sec-h">Notifications</h3>
db4e552594cbatagen2026-10-26 04:43 UTC25
    <span class="state" class:ok={on}>{unsupported ? 'Unavailable' : denied ? 'Blocked' : on ? 'On' : 'Off'}</span>
db4e552594cbatagen2026-10-26 04:43 UTC26
  </div>
db4e552594cbatagen2026-10-26 04:43 UTC27
  <button type="button" class="ghost-btn" disabled={busy || denied || unsupported} aria-pressed={on} on:click={() => void toggle()}>
db4e552594cbatagen2026-10-26 04:43 UTC28
    {on ? 'Turn off' : 'Turn on'}
db4e552594cbatagen2026-10-26 04:43 UTC29
  </button>
db4e552594cbatagen2026-10-26 04:43 UTC30
</section>
db4e552594cbatagen2026-10-26 04:43 UTC31
db4e552594cbatagen2026-10-26 04:43 UTC32
<style>
db4e552594cbatagen2026-10-26 04:43 UTC33
  section { margin-top: 18px; }
db4e552594cbatagen2026-10-26 04:43 UTC34
  .sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
db4e552594cbatagen2026-10-26 04:43 UTC35
  .sec-h { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; }
db4e552594cbatagen2026-10-26 04:43 UTC36
  .state { font-size: 12px; color: var(--muted); }
db4e552594cbatagen2026-10-26 04:43 UTC37
  .state.ok { color: var(--accent); }
db4e552594cbatagen2026-10-26 04:43 UTC38
</style>