mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-14 10:35:11 +00:00
firmware/reducers: remove 'flashing' state
The 'flashing' state variable in the firmware reducer is not used anymore so can be removed.
This commit is contained in:
@@ -2,15 +2,8 @@
|
||||
// Copyright (c) 2021-2026 The Pybricks Authors
|
||||
|
||||
import { AnyAction } from 'redux';
|
||||
import {
|
||||
FailToFinishReasonType,
|
||||
didFailToFinish,
|
||||
didFinish,
|
||||
didStart,
|
||||
} from './actions';
|
||||
import reducers from './reducers';
|
||||
|
||||
type State = ReturnType<typeof reducers>;
|
||||
import reducers from './reducers';
|
||||
|
||||
test('initial state', () => {
|
||||
expect(reducers(undefined, {} as AnyAction)).toMatchInlineSnapshot(`
|
||||
@@ -18,7 +11,6 @@ test('initial state', () => {
|
||||
"dfuWindowsDriverInstallDialog": {
|
||||
"isOpen": false,
|
||||
},
|
||||
"flashing": false,
|
||||
"installPybricksDialog": {
|
||||
"isOpen": false,
|
||||
},
|
||||
@@ -31,14 +23,3 @@ test('initial state', () => {
|
||||
}
|
||||
`);
|
||||
});
|
||||
|
||||
test('flashing', () => {
|
||||
expect(reducers({ flashing: false } as State, didStart()).flashing).toBe(true);
|
||||
expect(reducers({ flashing: true } as State, didFinish()).flashing).toBe(false);
|
||||
expect(
|
||||
reducers(
|
||||
{ flashing: true } as State,
|
||||
didFailToFinish(FailToFinishReasonType.TimedOut),
|
||||
).flashing,
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
import { Reducer, combineReducers } from 'redux';
|
||||
import {
|
||||
didFailToFinish,
|
||||
didFinish,
|
||||
didStart,
|
||||
firmwareDidFailToFlashUsbDfu,
|
||||
firmwareDidFailToRestoreOfficialDfu,
|
||||
firmwareDidFailToRestoreOfficialEV3,
|
||||
@@ -20,18 +17,6 @@ import dfuWindowsDriverInstallDialog from './dfuWindowsDriverInstallDialog/reduc
|
||||
import installPybricksDialog from './installPybricksDialog/reducers';
|
||||
import restoreOfficialDialog from './restoreOfficialDialog/reducers';
|
||||
|
||||
const flashing: Reducer<boolean> = (state = false, action) => {
|
||||
if (didStart.matches(action)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (didFinish.matches(action) || didFailToFinish.matches(action)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return state;
|
||||
};
|
||||
|
||||
const isFirmwareFlashUsbDfuInProgress: Reducer<boolean> = (state = false, action) => {
|
||||
if (firmwareFlashUsbDfu.matches(action)) {
|
||||
return true;
|
||||
@@ -86,7 +71,6 @@ export default combineReducers({
|
||||
dfuWindowsDriverInstallDialog,
|
||||
installPybricksDialog,
|
||||
restoreOfficialDialog,
|
||||
flashing,
|
||||
isFirmwareFlashUsbDfuInProgress,
|
||||
isFirmwareRestoreOfficialDfuInProgress,
|
||||
isFirmwareFlashEV3InProgress,
|
||||
|
||||
Reference in New Issue
Block a user