blob: a85cbb33dbd71fe05a7edecaa3c64d25ea0e5ef1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<script>
let { vapid, subscription, subscribe = async () => null } = $props();
let pending = $state(false);
function onsubmit(callback) {
return async (evt) => {
evt.preventDefault();
pending = true;
try {
await callback();
} finally {
pending = false;
}
};
}
</script>
{#if vapid !== null}
{#if subscription === null}
<form class="form" onsubmit={onsubmit(subscribe)}>
<button disabled={pending} type="submit">create push subscription</button>
</form>
{/if}
{:else}
Waiting for VAPID key…
{/if}
|