requestPermissions does not return a promise apparently
Test / test (push) Failing after 41s Details

This commit is contained in:
Jeff 2024-09-23 12:54:31 -04:00
parent 829c1ad343
commit 0c79ef491b
1 changed files with 10 additions and 5 deletions

View File

@ -72,13 +72,16 @@ function LandingMessage({ isSupported }: { isSupported: boolean }) {
} }
function EnableButton({ onSubscribe }: { onSubscribe: () => void }) { function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
const { subscribeToPush, requestPermission } = usePush() const { subscribeToPush, requestPermission, canSendPush } = usePush()
return <button onClick={subscribe}>Enable notifications</button>
async function subscribe() { async function subscribe() {
console.log("Hey the thing was clicked wow") console.log("Hey the thing was clicked wow")
await requestPermission() requestPermission()
}
useEffect(() => {
if (!canSendPush) return
subscribeToPush( subscribeToPush(
urlB64ToUint8Array(applicationServerPublicKey) as any, urlB64ToUint8Array(applicationServerPublicKey) as any,
(subscription) => { (subscription) => {
@ -94,7 +97,9 @@ function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
document.appendChild(errorDiv) document.appendChild(errorDiv)
} }
) )
} }, [canSendPush])
return <button onClick={subscribe}>Enable notifications</button>
} }
const applicationServerPublicKey = const applicationServerPublicKey =