diff --git a/src/get-next-connection-state.test.ts b/src/get-next-connection-state.test.ts index fbad8b2e3..7195b545f 100644 --- a/src/get-next-connection-state.test.ts +++ b/src/get-next-connection-state.test.ts @@ -342,9 +342,9 @@ describe("getNextConnectionState for radio connection", () => { type: "radioRemote", }, initialOnFirstConnectAttempt: false, - expectedOnFirstConnectAttempt: false, + expectedOnFirstConnectAttempt: true, initialHasAttemptedReconnect: true, - expectedHasAttemptedReconnect: true, + expectedHasAttemptedReconnect: false, expectedNextConnectionState: { status: ConnectionStatus.FailedToReconnectTwice, flowType: ConnectionFlowType.ConnectRadioRemote, @@ -548,9 +548,9 @@ describe("getNextConnectionState for bluetooth connection", () => { type: "bluetooth", }, initialOnFirstConnectAttempt: false, - expectedOnFirstConnectAttempt: false, + expectedOnFirstConnectAttempt: true, initialHasAttemptedReconnect: true, - expectedHasAttemptedReconnect: true, + expectedHasAttemptedReconnect: false, expectedNextConnectionState: { status: ConnectionStatus.FailedToReconnectTwice, flowType: ConnectionFlowType.ConnectBluetooth, diff --git a/src/get-next-connection-state.ts b/src/get-next-connection-state.ts index 268278ab2..259668b8f 100644 --- a/src/get-next-connection-state.ts +++ b/src/get-next-connection-state.ts @@ -148,6 +148,9 @@ export const getNextConnectionState = ({ hasAttempedReconnect && deviceStatus === DeviceConnectionStatus.DISCONNECTED ) { + // Reset connection state fields so that the next connection attempt is clean. + setOnFirstConnectAttempt(true); + setHasAttemptedReconnect(false); return { status: ConnectionStatus.FailedToReconnectTwice, flowType }; } if (