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