From 54a475cebc9a2cbe59d44e2dd7bb159a2164053b Mon Sep 17 00:00:00 2001 From: David Lechner Date: Sat, 26 Mar 2022 13:52:33 -0500 Subject: [PATCH] drop 'editor' saga context This is no longer used. --- src/app/App.tsx | 17 +++-------------- src/editor/Editor.tsx | 21 +++------------------ src/index.tsx | 5 +---- src/sagas.ts | 3 +-- 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/app/App.tsx b/src/app/App.tsx index 48eab1d8..e792e9ca 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -5,7 +5,7 @@ import { Classes } from '@blueprintjs/core'; import React, { useEffect, useState } from 'react'; import SplitterLayout from 'react-splitter-layout'; import { useLocalStorage, useTernaryDarkMode } from 'usehooks-ts'; -import Editor, { EditorType } from '../editor/Editor'; +import Editor from '../editor/Editor'; import Explorer from '../explorer/Explorer'; import { useSettingIsShowDocsEnabled } from '../settings/hooks'; import StatusBar from '../status-bar/StatusBar'; @@ -121,12 +121,7 @@ const Docs: React.VFC = () => { ); }; -type AppProps = { - /** Called when the editor is initialized. */ - onEditorChanged?: (editor: EditorType) => void; -}; - -const App: React.VoidFunctionComponent = ({ onEditorChanged }) => { +const App: React.VFC = () => { const { isDarkMode } = useTernaryDarkMode(); const { isSettingShowDocsEnabled } = useSettingIsShowDocsEnabled(); const [isDragging, setIsDragging] = useState(false); @@ -172,13 +167,7 @@ const App: React.VoidFunctionComponent = ({ onEditorChanged }) => { secondaryInitialSize={terminalSplit} onSecondaryPaneSizeChange={setTerminalSplit} > - { - if (onEditorChanged) { - onEditorChanged(editor); - } - }} - /> +
diff --git a/src/editor/Editor.tsx b/src/editor/Editor.tsx index 8fb376b7..4fe74159 100644 --- a/src/editor/Editor.tsx +++ b/src/editor/Editor.tsx @@ -26,11 +26,6 @@ import { UntitledHintContribution } from './untitledHint'; import './editor.scss'; -/** - * The editor type. Null indicates no current editor. - */ -export type EditorType = monaco.editor.ICodeEditor | null; - const pybricksMicroPythonId = 'pybricks-micropython'; monaco.languages.register({ id: pybricksMicroPythonId }); @@ -186,9 +181,7 @@ function useEditorAction( ); } -type EditorProps = { onEditorChanged?: (editor: EditorType) => void }; - -const Editor: React.VoidFunctionComponent = ({ onEditorChanged }) => { +const Editor: React.VFC = () => { const dispatch = useDispatch(); const [editor, setEditor] = useState(); @@ -265,21 +258,13 @@ const Editor: React.VoidFunctionComponent = ({ onEditorChanged }) = (editor) => { editor.focus(); setEditor(editor); - - if (onEditorChanged) { - onEditorChanged(editor); - } }, - [onEditorChanged, setEditor], + [setEditor], ); const handleEditorWillUnmount = useCallback(() => { - if (onEditorChanged) { - onEditorChanged(null); - } - setEditor(undefined); - }, [onEditorChanged, setEditor]); + }, [setEditor]); const handleChange = useCallback( // REVISIT: need to ensure we have exclusive access to file diff --git a/src/index.tsx b/src/index.tsx index 70651480..e88025fd 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -25,7 +25,6 @@ const toaster = I18nToaster.create(i18nManager); const sagaMiddleware = createSagaMiddleware({ context: { - editor: null, nextMessageId: createCountFunc(), notification: { toaster }, terminal: defaultTerminalContext, @@ -54,9 +53,7 @@ ReactDOM.render( - sagaMiddleware.setContext({ editor })} - /> + , diff --git a/src/sagas.ts b/src/sagas.ts index aed961d2..32ab3dc9 100644 --- a/src/sagas.ts +++ b/src/sagas.ts @@ -6,7 +6,6 @@ import { didStart } from './app/actions'; import app from './app/sagas'; import blePybricksService from './ble-pybricks-service/sagas'; import ble from './ble/sagas'; -import { EditorType } from './editor/Editor'; import editor from './editor/sagas'; import errorLog from './error-log/sagas'; import explorer from './explorer/sagas'; @@ -43,6 +42,6 @@ export default function* (): Generator { /** * Combined type for all saga contexts. */ -export type RootSagaContext = { editor: EditorType } & FirmwareSagaContext & +export type RootSagaContext = FirmwareSagaContext & NotificationSagaContext & TerminalSagaContext;