Skip to content

Commit 1fe01b5

Browse files
committed
status-bar: make visibility depend on runtime state
Change dependency on Bluetooth connection state to runtime state. This way it works for USB connection as well.
1 parent 3c4cc20 commit 1fe01b5

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/status-bar/StatusBar.test.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2021-2023 The Pybricks Authors
2+
// Copyright (c) 2021-2025 The Pybricks Authors
33

44
import { act, waitFor } from '@testing-library/react';
55
import React from 'react';
66
import { testRender } from '../../test';
77
import { BleConnectionState } from '../ble/reducers';
8+
import { HubRuntimeState } from '../hub/reducers';
89
import StatusBar from './StatusBar';
910

1011
it('should show popover when hub name is clicked', async () => {
@@ -19,6 +20,7 @@ it('should show popover when hub name is clicked', async () => {
1920
deviceLowBatteryWarning: false,
2021
deviceBatteryCharging: false,
2122
},
23+
hub: { runtime: HubRuntimeState.Idle },
2224
});
2325

2426
await act(() => user.click(statusBar.getByText(testHubName)));
@@ -38,6 +40,7 @@ it('should show popover when battery is clicked', async () => {
3840
deviceLowBatteryWarning: false,
3941
deviceBatteryCharging: false,
4042
},
43+
hub: { runtime: HubRuntimeState.Idle },
4144
});
4245

4346
await act(() => user.click(statusBar.getByTitle('Battery')));

src/status-bar/StatusBar.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// SPDX-License-Identifier: MIT
2-
// Copyright (c) 2020-2023 The Pybricks Authors
2+
// Copyright (c) 2020-2025 The Pybricks Authors
33

44
import './status-bar.scss';
55
import {
@@ -16,8 +16,8 @@ import {
1616
import { Disable, Error, TickCircle } from '@blueprintjs/icons';
1717
import classNames from 'classnames';
1818
import React, { useMemo } from 'react';
19-
import { BleConnectionState } from '../ble/reducers';
2019
import { CompletionEngineStatus } from '../editor/redux/codeCompletion';
20+
import { HubRuntimeState } from '../hub/reducers';
2121
import { useSelector } from '../reducers';
2222
import { useI18n } from './i18n';
2323

@@ -144,7 +144,7 @@ const BatteryIndicator: React.FunctionComponent = () => {
144144
};
145145

146146
const StatusBar: React.FunctionComponent = () => {
147-
const connection = useSelector((s) => s.ble.connection);
147+
const runtime = useSelector((s) => s.hub.runtime);
148148

149149
return (
150150
<div
@@ -156,7 +156,7 @@ const StatusBar: React.FunctionComponent = () => {
156156
<CompletionEngineIndicator />
157157
</div>
158158
<div className="pb-status-bar-group">
159-
{connection === BleConnectionState.Connected && (
159+
{runtime !== HubRuntimeState.Disconnected && (
160160
<>
161161
<HubInfoButton />
162162
<BatteryIndicator />

0 commit comments

Comments
 (0)