Show error when enabling notifications
Test / test (push) Failing after 54s Details

This commit is contained in:
Jeff 2024-10-12 13:58:46 -04:00
parent a23f5bdd4a
commit d655492d16
1 changed files with 12 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import React from "react" import React, { useState } from "react"
import { useEffect } from "react" import { useEffect } from "react"
import { usePush } from "../usePush" import { usePush } from "../usePush"
import { request } from "http" import { request } from "http"
@ -25,6 +25,8 @@ export default function EnableNotifications({
function EnableButton({ onSubscribe }: { onSubscribe: () => void }) { function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
const { subscribeToPush, requestPermission, canSendPush } = usePush() const { subscribeToPush, requestPermission, canSendPush } = usePush()
const [error, setError] = useState<Error>()
function subscribe() { function subscribe() {
requestPermission() requestPermission()
} }
@ -40,9 +42,17 @@ function EnableButton({ onSubscribe }: { onSubscribe: () => void }) {
subscription, subscription,
}) })
onSubscribe() onSubscribe()
},
(error) => {
setError(error)
} }
) )
}, [canSendPush]) }, [canSendPush])
return <button onClick={subscribe}>Enable Notifications</button> return (
<>
<button onClick={subscribe}>Enable Notifications</button>
<div>{error?.toString()}</div>
</>
)
} }