From 88fad1735702d92266d7f8dab7b6e6772d0c3c53 Mon Sep 17 00:00:00 2001 From: Jeremy Kahn Date: Tue, 28 Mar 2023 09:38:57 -0500 Subject: [PATCH] fix: improve connection loss handling --- src/components/Shell/useConnectionTest.ts | 24 ++++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/components/Shell/useConnectionTest.ts b/src/components/Shell/useConnectionTest.ts index f1bfc7c..8b0bc48 100644 --- a/src/components/Shell/useConnectionTest.ts +++ b/src/components/Shell/useConnectionTest.ts @@ -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(