mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
hub: fix buttons not enabled after connection
A previous commit broke buttons after connecting since state all state
transitions were changed to be ignored if the current state was
"disconnected". This made it impossible to get into any other state.
This brings back use of the "unknown" state upon initial connection
to provide a path out of the "disconnected" state.
Fixes: 7a5aa75894
This commit is contained in:
committed by
David Lechner
parent
d95c550248
commit
4e2902730a
@@ -4,7 +4,7 @@
|
||||
import { Action } from '../actions';
|
||||
import { statusReportEvent } from '../ble-pybricks-service/actions';
|
||||
import { Status, statusToFlag } from '../ble-pybricks-service/protocol';
|
||||
import { didDisconnect } from '../ble/actions';
|
||||
import { didConnect, didDisconnect } from '../ble/actions';
|
||||
import {
|
||||
didFailToFinishDownload,
|
||||
didFinishDownload,
|
||||
@@ -25,6 +25,13 @@ test('initial state', () => {
|
||||
});
|
||||
|
||||
describe('runtime', () => {
|
||||
test('', () => {
|
||||
expect(
|
||||
reducers({ runtime: HubRuntimeState.Disconnected } as State, didConnect())
|
||||
.runtime,
|
||||
).toBe(HubRuntimeState.Unknown);
|
||||
});
|
||||
|
||||
test.each(Object.values(HubRuntimeState))('didDisconnect', (startingState) => {
|
||||
// all states are overridden by disconnect
|
||||
expect(
|
||||
|
||||
@@ -43,6 +43,8 @@ const runtime: Reducer<HubRuntimeState, Action> = (
|
||||
action,
|
||||
) => {
|
||||
switch (action.type) {
|
||||
case BleDeviceActionType.DidConnect:
|
||||
return HubRuntimeState.Unknown;
|
||||
case BleDeviceActionType.DidDisconnect:
|
||||
return HubRuntimeState.Disconnected;
|
||||
case HubActionType.DidStartDownload:
|
||||
|
||||
Reference in New Issue
Block a user