mirror of
https://github.com/pybricks/pybricks-code.git
synced 2026-09-15 02:54:07 +00:00
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
28 lines
636 B
TypeScript
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 });
|