Merge pull request #388 from pybricks/dlech

beta 10
This commit is contained in:
David Lechner
2021-04-06 13:55:49 -05:00
committed by GitHub
3 changed files with 11 additions and 10 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@pybricks/pybricks-code",
"version": "1.0.0-beta.9",
"version": "1.0.0-beta.10",
"license": "MIT",
"author": "The Pybricks Authors",
"repository": {
-2
View File
@@ -4,10 +4,8 @@
import { Action } from 'redux';
export enum HubRuntimeStatusType {
Idle = 'idle',
Loading = 'loading',
Loaded = 'loaded',
Running = 'running',
Error = 'error',
}
+10 -7
View File
@@ -51,14 +51,10 @@ const runtime: Reducer<HubRuntimeState, Action> = (
return HubRuntimeState.Disconnected;
case HubMessageActionType.RuntimeStatus:
switch (action.newStatus) {
case HubRuntimeStatusType.Idle:
return HubRuntimeState.Idle;
case HubRuntimeStatusType.Loading:
return HubRuntimeState.Loading;
case HubRuntimeStatusType.Loaded:
return HubRuntimeState.Loaded;
case HubRuntimeStatusType.Running:
return HubRuntimeState.Running;
case HubRuntimeStatusType.Error:
return HubRuntimeState.Error;
default:
@@ -66,9 +62,16 @@ const runtime: Reducer<HubRuntimeState, Action> = (
return state;
}
case BlePybricksServiceEventActionType.StatusReport:
return action.statusFlags & statusToFlag(Status.UserProgramRunning)
? HubRuntimeState.Running
: HubRuntimeState.Idle;
if (action.statusFlags & statusToFlag(Status.UserProgramRunning)) {
return HubRuntimeState.Running;
}
// TODO: Status report flags should probably separated from hub runtime state.
// For now, we have this hack to ensure status updates don't interfere with
// download and run
if (state !== HubRuntimeState.Loading && state !== HubRuntimeState.Loaded) {
return HubRuntimeState.Idle;
}
return state;
default:
return state;
}