mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-12 01:23:52 +00:00
+1
-1
@@ -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": {
|
||||
|
||||
@@ -4,10 +4,8 @@
|
||||
import { Action } from 'redux';
|
||||
|
||||
export enum HubRuntimeStatusType {
|
||||
Idle = 'idle',
|
||||
Loading = 'loading',
|
||||
Loaded = 'loaded',
|
||||
Running = 'running',
|
||||
Error = 'error',
|
||||
}
|
||||
|
||||
|
||||
+10
-7
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user