diff --git a/package-lock.json b/package-lock.json index e3e10c9..c7328de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,7 +31,7 @@ "p-throttle": "~6.1.0", "preact": "~10.20.1", "punycode": "~2.3.1", - "react-hotkeys-hook": "~5.0.0-1", + "react-hotkeys-hook": "~4.5.0", "react-intersection-observer": "~9.8.1", "react-quick-pinch-zoom": "~5.1.0", "react-router-dom": "6.6.2", @@ -7221,9 +7221,9 @@ } }, "node_modules/react-hotkeys-hook": { - "version": "5.0.0-1", - "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-5.0.0-1.tgz", - "integrity": "sha512-nb8WD8IBrlEn3O2nlMoaBrWCxg2/vjgK3XFquDMM50qMbRzlOrR/p4PUlvh0rfuOMqEtKTGaL5BwkCh3rZ3T1w==", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-4.5.0.tgz", + "integrity": "sha512-Samb85GSgAWFQNvVt3PS90LPPGSf9mkH/r4au81ZP1yOIFayLC3QAvqTgGtJ8YEDMXtPmaVBs6NgipHO6h4Mug==", "peerDependencies": { "react": ">=16.8.1", "react-dom": ">=16.8.1" diff --git a/package.json b/package.json index 90f940e..a6f2497 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "p-throttle": "~6.1.0", "preact": "~10.20.1", "punycode": "~2.3.1", - "react-hotkeys-hook": "~5.0.0-1", + "react-hotkeys-hook": "~4.5.0", "react-intersection-observer": "~9.8.1", "react-quick-pinch-zoom": "~5.1.0", "react-router-dom": "6.6.2", diff --git a/src/components/background-service.jsx b/src/components/background-service.jsx index 08026d6..15647fe 100644 --- a/src/components/background-service.jsx +++ b/src/components/background-service.jsx @@ -1,10 +1,10 @@ import { memo } from 'preact/compat'; import { useEffect, useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { api } from '../utils/api'; import showToast from '../utils/show-toast'; import states, { saveStatus } from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import useInterval from '../utils/useInterval'; import usePageVisibility from '../utils/usePageVisibility'; diff --git a/src/components/columns.jsx b/src/components/columns.jsx index 5d57b75..f21e116 100644 --- a/src/components/columns.jsx +++ b/src/components/columns.jsx @@ -1,3 +1,4 @@ +import { useHotkeys } from 'react-hotkeys-hook'; import { useSnapshot } from 'valtio'; import Bookmarks from '../pages/bookmarks'; @@ -11,7 +12,6 @@ import Public from '../pages/public'; import Search from '../pages/search'; import Trending from '../pages/trending'; import states from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import useTitle from '../utils/useTitle'; function Columns() { diff --git a/src/components/compose-button.jsx b/src/components/compose-button.jsx index a9c21f8..ef64adf 100644 --- a/src/components/compose-button.jsx +++ b/src/components/compose-button.jsx @@ -1,7 +1,8 @@ +import { useHotkeys } from 'react-hotkeys-hook'; + import openCompose from '../utils/open-compose'; import openOSK from '../utils/open-osk'; import states from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import Icon from './icon'; diff --git a/src/components/compose.jsx b/src/components/compose.jsx index 0f93a28..6506d73 100644 --- a/src/components/compose.jsx +++ b/src/components/compose.jsx @@ -5,6 +5,7 @@ import { MenuItem } from '@szhsin/react-menu'; import { deepEqual } from 'fast-equals'; import { forwardRef } from 'preact/compat'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import stringLength from 'string-length'; import { uid } from 'uid/single'; import { useDebouncedCallback, useThrottledCallback } from 'use-debounce'; @@ -32,7 +33,6 @@ import { } from '../utils/store-utils'; import supports from '../utils/supports'; import useCloseWatcher from '../utils/useCloseWatcher'; -import useHotkeys from '../utils/useHotkeys'; import useInterval from '../utils/useInterval'; import visibilityIconsMap from '../utils/visibility-icons-map'; diff --git a/src/components/keyboard-shortcuts-help.jsx b/src/components/keyboard-shortcuts-help.jsx index b2bc290..a3925f2 100644 --- a/src/components/keyboard-shortcuts-help.jsx +++ b/src/components/keyboard-shortcuts-help.jsx @@ -1,10 +1,10 @@ import './keyboard-shortcuts-help.css'; import { memo } from 'preact/compat'; +import { useHotkeys } from 'react-hotkeys-hook'; import { useSnapshot } from 'valtio'; import states from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import Icon from './icon'; import Modal from './modal'; diff --git a/src/components/media-modal.jsx b/src/components/media-modal.jsx index e4bd93c..968988b 100644 --- a/src/components/media-modal.jsx +++ b/src/components/media-modal.jsx @@ -7,11 +7,11 @@ import { useRef, useState, } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { oklab2rgb, rgb2oklab } from '../utils/color-utils'; import showToast from '../utils/show-toast'; import states from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import Icon from './icon'; import Link from './link'; diff --git a/src/components/modal.jsx b/src/components/modal.jsx index 3cdc4d2..f1aaaf0 100644 --- a/src/components/modal.jsx +++ b/src/components/modal.jsx @@ -2,9 +2,9 @@ import './modal.css'; import { createPortal } from 'preact/compat'; import { useEffect, useRef } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import useCloseWatcher from '../utils/useCloseWatcher'; -import useHotkeys from '../utils/useHotkeys'; const $modalContainer = document.getElementById('modal-container'); diff --git a/src/components/search-command.jsx b/src/components/search-command.jsx index cba31be..c40a92f 100644 --- a/src/components/search-command.jsx +++ b/src/components/search-command.jsx @@ -2,8 +2,7 @@ import './search-command.css'; import { memo } from 'preact/compat'; import { useRef, useState } from 'preact/hooks'; - -import useHotkeys from '../utils/useHotkeys'; +import { useHotkeys } from 'react-hotkeys-hook'; import SearchForm from './search-form'; diff --git a/src/components/shortcuts.jsx b/src/components/shortcuts.jsx index f043a94..ddbe9cd 100644 --- a/src/components/shortcuts.jsx +++ b/src/components/shortcuts.jsx @@ -3,6 +3,7 @@ import './shortcuts.css'; import { MenuDivider } from '@szhsin/react-menu'; import { memo } from 'preact/compat'; import { useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { useNavigate } from 'react-router-dom'; import { useSnapshot } from 'valtio'; @@ -10,7 +11,6 @@ import { SHORTCUTS_META } from '../components/shortcuts-settings'; import { api } from '../utils/api'; import { getLists } from '../utils/lists'; import states from '../utils/states'; -import useHotkeys from '../utils/useHotkeys'; import AsyncText from './AsyncText'; import Icon from './icon'; diff --git a/src/components/status.jsx b/src/components/status.jsx index 2647ff6..c359872 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -22,6 +22,7 @@ import { useState, } from 'preact/hooks'; import punycode from 'punycode'; +import { useHotkeys } from 'react-hotkeys-hook'; import { useLongPress } from 'use-long-press'; import { useSnapshot } from 'valtio'; @@ -58,7 +59,6 @@ import store from '../utils/store'; import { getCurrentAccountID } from '../utils/store-utils'; import supports from '../utils/supports'; import unfurlMastodonLink from '../utils/unfurl-link'; -import useHotkeys from '../utils/useHotkeys'; import useTruncated from '../utils/useTruncated'; import visibilityIconsMap from '../utils/visibility-icons-map'; diff --git a/src/components/timeline.jsx b/src/components/timeline.jsx index 33cdc9e..6fe1273 100644 --- a/src/components/timeline.jsx +++ b/src/components/timeline.jsx @@ -6,6 +6,7 @@ import { useRef, useState, } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { InView } from 'react-intersection-observer'; import { useDebouncedCallback } from 'use-debounce'; import { useSnapshot } from 'valtio'; @@ -16,7 +17,6 @@ import states, { statusKey } from '../utils/states'; import statusPeek from '../utils/status-peek'; import { isMediaFirstInstance } from '../utils/store-utils'; import { groupBoosts, groupContext } from '../utils/timeline-utils'; -import useHotkeys from '../utils/useHotkeys'; import useInterval from '../utils/useInterval'; import usePageVisibility from '../utils/usePageVisibility'; import useScroll from '../utils/useScroll'; diff --git a/src/pages/catchup.jsx b/src/pages/catchup.jsx index e416d2e..433eed3 100644 --- a/src/pages/catchup.jsx +++ b/src/pages/catchup.jsx @@ -14,6 +14,7 @@ import { useState, } from 'preact/hooks'; import punycode from 'punycode'; +import { useHotkeys } from 'react-hotkeys-hook'; import { useSearchParams } from 'react-router-dom'; import { uid } from 'uid/single'; @@ -41,7 +42,6 @@ import statusPeek from '../utils/status-peek'; import store from '../utils/store'; import { getCurrentAccountID, getCurrentAccountNS } from '../utils/store-utils'; import { assignFollowedTags } from '../utils/timeline-utils'; -import useHotkeys from '../utils/useHotkeys'; import useTitle from '../utils/useTitle'; const FILTER_CONTEXT = 'home'; diff --git a/src/pages/notifications.jsx b/src/pages/notifications.jsx index a8434c9..e97d8aa 100644 --- a/src/pages/notifications.jsx +++ b/src/pages/notifications.jsx @@ -3,6 +3,7 @@ import './notifications.css'; import { Fragment } from 'preact'; import { memo } from 'preact/compat'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { InView } from 'react-intersection-observer'; import { useSearchParams } from 'react-router-dom'; import { useSnapshot } from 'valtio'; @@ -28,7 +29,6 @@ import showToast from '../utils/show-toast'; import states, { saveStatus } from '../utils/states'; import { getCurrentInstance } from '../utils/store-utils'; import supports from '../utils/supports'; -import useHotkeys from '../utils/useHotkeys'; import usePageVisibility from '../utils/usePageVisibility'; import useScroll from '../utils/useScroll'; import useTitle from '../utils/useTitle'; diff --git a/src/pages/search.jsx b/src/pages/search.jsx index 315bc41..37b30e4 100644 --- a/src/pages/search.jsx +++ b/src/pages/search.jsx @@ -2,6 +2,7 @@ import './search.css'; import { useAutoAnimate } from '@formkit/auto-animate/preact'; import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'; +import { useHotkeys } from 'react-hotkeys-hook'; import { InView } from 'react-intersection-observer'; import { useParams, useSearchParams } from 'react-router-dom'; @@ -15,7 +16,6 @@ import Status from '../components/status'; import { api } from '../utils/api'; import { fetchRelationships } from '../utils/relationships'; import shortenNumber from '../utils/shorten-number'; -import useHotkeys from '../utils/useHotkeys'; import usePageVisibility from '../utils/usePageVisibility'; import useTitle from '../utils/useTitle'; diff --git a/src/pages/status.jsx b/src/pages/status.jsx index 25a9708..50c3b30 100644 --- a/src/pages/status.jsx +++ b/src/pages/status.jsx @@ -13,6 +13,7 @@ import { useState, } from 'preact/hooks'; import punycode from 'punycode'; +import { useHotkeys } from 'react-hotkeys-hook'; import { InView } from 'react-intersection-observer'; import { matchPath, useSearchParams } from 'react-router-dom'; import { useSnapshot } from 'valtio'; @@ -37,7 +38,6 @@ import states, { } from '../utils/states'; import statusPeek from '../utils/status-peek'; import { getCurrentAccount } from '../utils/store-utils'; -import useHotkeys from '../utils/useHotkeys'; import useScroll from '../utils/useScroll'; import useTitle from '../utils/useTitle'; diff --git a/src/utils/useHotkeys.js b/src/utils/useHotkeys.js deleted file mode 100644 index d3a78a2..0000000 --- a/src/utils/useHotkeys.js +++ /dev/null @@ -1,16 +0,0 @@ -import { useHotkeys } from 'react-hotkeys-hook'; - -// Patch useHotKeys to add additional option -// E.g. useHotkeys('!', callback, {useKey: true}) - -export default function (keys, callback, options, deps) { - return useHotkeys( - keys, - callback, - { - useKey: true, - ...options, - }, - deps, - ); -}