Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start over if the initial connection fails twice #500

Merged
merged 6 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/get-next-connection-state.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ describe("getNextConnectionState for radio connection", () => {
type: "radioRemote",
},
initialOnFirstConnectAttempt: true,
expectedOnFirstConnectAttempt: true,
expectedOnFirstConnectAttempt: false,
initialHasAttemptedReconnect: false,
expectedHasAttemptedReconnect: false,
expectedHasAttemptedReconnect: true,
expectedNextConnectionState: {
status: ConnectionStatus.FailedToConnect,
flowType: ConnectionFlowType.ConnectRadioRemote,
Expand Down Expand Up @@ -456,9 +456,9 @@ describe("getNextConnectionState for bluetooth connection", () => {
type: "bluetooth",
},
initialOnFirstConnectAttempt: true,
expectedOnFirstConnectAttempt: true,
expectedOnFirstConnectAttempt: false,
initialHasAttemptedReconnect: false,
expectedHasAttemptedReconnect: false,
expectedHasAttemptedReconnect: true,
expectedNextConnectionState: {
status: ConnectionStatus.FailedToConnect,
flowType: ConnectionFlowType.ConnectBluetooth,
Expand Down
5 changes: 5 additions & 0 deletions src/get-next-connection-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export const getNextConnectionState = ({
currStatus === ConnectionStatus.Connecting &&
deviceStatus === DeviceConnectionStatus.DISCONNECTED
) {
// We count this as the first connect failure.
// If we fail a second time, we should prompt the user to start over.
// Set the fields below appropriately to acheive this.
setOnFirstConnectAttempt(false);
setHasAttemptedReconnect(true);
return { status: ConnectionStatus.FailedToConnect, flowType };
}
if (
Expand Down
Loading