diff --git a/src/actions.ts b/src/actions.ts index dd4ea67b..5e3f6087 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,8 +1,6 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020-2022 The Pybricks Authors -import { useDispatch as useReduxDispatch } from 'react-redux'; -import { Dispatch as ReduxDispatch } from 'redux'; import { AppAction } from './app/actions'; import { BleDIServiceAction } from './ble-device-info-service/actions'; import { BleUartAction } from './ble-nordic-uart-service/actions'; @@ -58,13 +56,3 @@ export type Action = | ServiceWorkerAction | SettingsAction | TerminalDataAction; - -/** - * Dispatch function. - */ -export type Dispatch = ReduxDispatch; - -/** - * Typed version of Redux useDispatch() hook. - */ -export const useDispatch = (): Dispatch => useReduxDispatch(); diff --git a/src/app/App.tsx b/src/app/App.tsx index bba931ce..60f7e211 100644 --- a/src/app/App.tsx +++ b/src/app/App.tsx @@ -3,8 +3,8 @@ import { Classes } from '@blueprintjs/core'; import React, { useEffect, useState } from 'react'; +import { useDispatch } from 'react-redux'; import SplitterLayout from 'react-splitter-layout'; -import { useDispatch } from '../actions'; import Editor from '../editor/Editor'; import { useSelector } from '../reducers'; import { toggleBoolean } from '../settings/actions'; diff --git a/src/editor/Editor.tsx b/src/editor/Editor.tsx index e014ca55..9fc930c0 100644 --- a/src/editor/Editor.tsx +++ b/src/editor/Editor.tsx @@ -12,8 +12,8 @@ import tomorrowNightEightiesTheme from 'monaco-themes/themes/Tomorrow-Night-Eigh import xcodeTheme from 'monaco-themes/themes/Xcode_default.json'; import React, { useRef } from 'react'; import MonacoEditor, { monaco } from 'react-monaco-editor'; +import { useDispatch } from 'react-redux'; import { IDisposable } from 'xterm'; -import { useDispatch } from '../actions'; import { fileStorageWriteFile } from '../fileStorage/actions'; import { compile } from '../mpy/actions'; import { useSelector } from '../reducers'; diff --git a/src/editor/OpenButton.tsx b/src/editor/OpenButton.tsx index b5e77ded..f5cf187e 100644 --- a/src/editor/OpenButton.tsx +++ b/src/editor/OpenButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import * as notificationActions from '../notifications/actions'; import { useSelector } from '../reducers'; import OpenFileButton, { OpenFileButtonProps } from '../toolbar/OpenFileButton'; diff --git a/src/editor/SaveAsButton.tsx b/src/editor/SaveAsButton.tsx index 26e991d9..d7c0d374 100644 --- a/src/editor/SaveAsButton.tsx +++ b/src/editor/SaveAsButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import * as editorActions from '../editor/actions'; import { useSelector } from '../reducers'; import ActionButton, { ActionButtonProps } from '../toolbar/ActionButton'; diff --git a/src/firmware/FlashButton.tsx b/src/firmware/FlashButton.tsx index 781f14b2..4c319837 100644 --- a/src/firmware/FlashButton.tsx +++ b/src/firmware/FlashButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import { BleConnectionState } from '../ble/reducers'; import { BootloaderConnectionState } from '../lwp3-bootloader/reducers'; import * as notificationActions from '../notifications/actions'; diff --git a/src/hub/BluetoothButton.tsx b/src/hub/BluetoothButton.tsx index 51595388..94eade97 100644 --- a/src/hub/BluetoothButton.tsx +++ b/src/hub/BluetoothButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import { toggleBluetooth } from '../ble/actions'; import { BleConnectionState } from '../ble/reducers'; import { BootloaderConnectionState } from '../lwp3-bootloader/reducers'; diff --git a/src/hub/RunButton.tsx b/src/hub/RunButton.tsx index 31961d62..33955423 100644 --- a/src/hub/RunButton.tsx +++ b/src/hub/RunButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import { useSelector } from '../reducers'; import ActionButton, { ActionButtonProps } from '../toolbar/ActionButton'; import { TooltipId } from '../toolbar/i18n'; diff --git a/src/hub/StopButton.tsx b/src/hub/StopButton.tsx index 76fb80b1..69a24cf1 100644 --- a/src/hub/StopButton.tsx +++ b/src/hub/StopButton.tsx @@ -2,7 +2,7 @@ // Copyright (c) 2020-2021 The Pybricks Authors import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import { useSelector } from '../reducers'; import ActionButton, { ActionButtonProps } from '../toolbar/ActionButton'; import { TooltipId } from '../toolbar/i18n'; diff --git a/src/licenses/LicenseDialog.tsx b/src/licenses/LicenseDialog.tsx index bb20d3f3..d4d8ad8e 100644 --- a/src/licenses/LicenseDialog.tsx +++ b/src/licenses/LicenseDialog.tsx @@ -14,7 +14,7 @@ import { } from '@blueprintjs/core'; import { useI18n } from '@shopify/react-i18n'; import React from 'react'; -import { useDispatch } from '../actions'; +import { useDispatch } from 'react-redux'; import { appName } from '../app/constants'; import { useSelector } from '../reducers'; import { fetchList, select } from './actions'; diff --git a/src/settings/SettingsDrawer.tsx b/src/settings/SettingsDrawer.tsx index 7dd6686f..7e21e08c 100644 --- a/src/settings/SettingsDrawer.tsx +++ b/src/settings/SettingsDrawer.tsx @@ -19,8 +19,8 @@ import { import { Tooltip2 } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; import React, { useMemo, useState } from 'react'; +import { useDispatch } from 'react-redux'; import AboutDialog from '../about/AboutDialog'; -import { useDispatch } from '../actions'; import { checkForUpdate, installPrompt, reload } from '../app/actions'; import { pybricksBugReportsUrl, diff --git a/src/terminal/Terminal.tsx b/src/terminal/Terminal.tsx index c327fa46..e7dfe032 100644 --- a/src/terminal/Terminal.tsx +++ b/src/terminal/Terminal.tsx @@ -5,9 +5,9 @@ import { Menu, MenuDivider, MenuItem, ResizeSensor } from '@blueprintjs/core'; import { ContextMenu2, ContextMenu2ContentProps } from '@blueprintjs/popover2'; import { useI18n } from '@shopify/react-i18n'; import React, { useContext, useEffect, useMemo, useRef } from 'react'; +import { useDispatch } from 'react-redux'; import { Terminal as XTerm } from 'xterm'; import { FitAddon } from 'xterm-addon-fit'; -import { useDispatch } from '../actions'; import { useSelector } from '../reducers'; import { isMacOS } from '../utils/os'; import { TerminalContext } from './TerminalContext';