Files
pybricks-code/src/explorer/newFileWizard/reducers.ts
T
David Lechner fad7b0114a explorer/newFileWizard: refactor
This refactors the new file wizard to be more independent. Most of the
control is now done through the saga instead of splitting it between
react and the sagas.

Also fix a few issues while we are touching this:
- pressing enter now accepts the dialog
- newly created file is now activated in the editor
2022-04-08 10:52:54 -05:00

28 lines
636 B
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2022 The Pybricks Authors
import { Reducer, combineReducers } from 'redux';
import {
newFileWizardDidAccept,
newFileWizardDidCancel,
newFileWizardShow,
} from './actions';
/** Controls the new file wizard dialog isOpen state. */
const isOpen: Reducer<boolean> = (state = false, action) => {
if (newFileWizardShow.matches(action)) {
return true;
}
if (
newFileWizardDidAccept.matches(action) ||
newFileWizardDidCancel.matches(action)
) {
return false;
}
return state;
};
export default combineReducers({ isOpen });