Skip to content

Commit

Permalink
Fix for unplugging link micro:bit when on another tab
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-robert committed Nov 15, 2024
1 parent 8a04862 commit 12fb5c6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/get-next-connection-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export const getNextConnectionState = (
: ConnectionStatus.FailedToReconnect;
return { status, flowType };
}

if (
// If user starts or restarts connection flow.
// Disconnection happens for newly started / restarted
Expand Down Expand Up @@ -190,5 +189,17 @@ export const getNextConnectionState = (
) {
return { status: ConnectionStatus.ReconnectingAutomatically, flowType };
}
if (
DeviceConnectionStatus.NO_AUTHORIZED_DEVICE &&
ConnectionStatus.ReconnectingAutomatically &&
currConnType === "radio"
) {
// The link micro:bit was unplugged while the user was viewing another tab.
// On return, show failed to reconnect.
return {
status: ConnectionStatus.FailedToReconnect,
flowType: ConnectionFlowType.ConnectRadioBridge,
};
}
return undefined;
};

0 comments on commit 12fb5c6

Please sign in to comment.