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