fix: improve connection loss handling

This commit is contained in:
Jeremy Kahn 2023-03-28 09:38:57 -05:00
parent 8fa4f666e0
commit 88fad17357

View File

@ -22,14 +22,12 @@ export const useConnectionTest = () => {
const connectionTest = new ConnectionTest()
const handleHasHostChanged = ((event: ConnectionTestEvent) => {
if (event.detail.hasHost) {
setHasHost(true)
setHasHost(event.detail.hasHost)
connectionTest.removeEventListener(
ConnectionTestEvents.HAS_HOST_CHANGED,
handleHasHostChanged
)
}
connectionTest.removeEventListener(
ConnectionTestEvents.HAS_HOST_CHANGED,
handleHasHostChanged
)
}) as EventListener
connectionTest.addEventListener(
@ -38,14 +36,12 @@ export const useConnectionTest = () => {
)
const handleHasRelayChanged = ((event: ConnectionTestEvent) => {
if (event.detail.hasRelay) {
setHasRelay(true)
setHasRelay(event.detail.hasRelay)
connectionTest.removeEventListener(
ConnectionTestEvents.HAS_RELAY_CHANGED,
handleHasRelayChanged
)
}
connectionTest.removeEventListener(
ConnectionTestEvents.HAS_RELAY_CHANGED,
handleHasRelayChanged
)
}) as EventListener
connectionTest.addEventListener(