Show error when enabling notifications
Test / test (push) Failing after 54s
Details
Test / test (push) Failing after 54s
Details
This commit is contained in:
parent
a23f5bdd4a
commit
d655492d16
|
|
@ -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>
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue