Test upgrade react-hotkeys-hook for the keys fix

This commit is contained in:
Lim Chee Aun 2024-04-12 23:56:34 +08:00
parent 7fb56d9f6c
commit 9285a0ba9a
18 changed files with 37 additions and 21 deletions

8
package-lock.json generated
View file

@ -31,7 +31,7 @@
"p-throttle": "~6.1.0", "p-throttle": "~6.1.0",
"preact": "~10.20.1", "preact": "~10.20.1",
"punycode": "~2.3.1", "punycode": "~2.3.1",
"react-hotkeys-hook": "~4.5.0", "react-hotkeys-hook": "~5.0.0-1",
"react-intersection-observer": "~9.8.1", "react-intersection-observer": "~9.8.1",
"react-quick-pinch-zoom": "~5.1.0", "react-quick-pinch-zoom": "~5.1.0",
"react-router-dom": "6.6.2", "react-router-dom": "6.6.2",
@ -7221,9 +7221,9 @@
} }
}, },
"node_modules/react-hotkeys-hook": { "node_modules/react-hotkeys-hook": {
"version": "4.5.0", "version": "5.0.0-1",
"resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-4.5.0.tgz", "resolved": "https://registry.npmjs.org/react-hotkeys-hook/-/react-hotkeys-hook-5.0.0-1.tgz",
"integrity": "sha512-Samb85GSgAWFQNvVt3PS90LPPGSf9mkH/r4au81ZP1yOIFayLC3QAvqTgGtJ8YEDMXtPmaVBs6NgipHO6h4Mug==", "integrity": "sha512-nb8WD8IBrlEn3O2nlMoaBrWCxg2/vjgK3XFquDMM50qMbRzlOrR/p4PUlvh0rfuOMqEtKTGaL5BwkCh3rZ3T1w==",
"peerDependencies": { "peerDependencies": {
"react": ">=16.8.1", "react": ">=16.8.1",
"react-dom": ">=16.8.1" "react-dom": ">=16.8.1"

View file

@ -33,7 +33,7 @@
"p-throttle": "~6.1.0", "p-throttle": "~6.1.0",
"preact": "~10.20.1", "preact": "~10.20.1",
"punycode": "~2.3.1", "punycode": "~2.3.1",
"react-hotkeys-hook": "~4.5.0", "react-hotkeys-hook": "~5.0.0-1",
"react-intersection-observer": "~9.8.1", "react-intersection-observer": "~9.8.1",
"react-quick-pinch-zoom": "~5.1.0", "react-quick-pinch-zoom": "~5.1.0",
"react-router-dom": "6.6.2", "react-router-dom": "6.6.2",

View file

@ -1,10 +1,10 @@
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { useEffect, useRef, useState } from 'preact/hooks'; import { useEffect, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { api } from '../utils/api'; import { api } from '../utils/api';
import showToast from '../utils/show-toast'; import showToast from '../utils/show-toast';
import states, { saveStatus } from '../utils/states'; import states, { saveStatus } from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import useInterval from '../utils/useInterval'; import useInterval from '../utils/useInterval';
import usePageVisibility from '../utils/usePageVisibility'; import usePageVisibility from '../utils/usePageVisibility';

View file

@ -1,4 +1,3 @@
import { useHotkeys } from 'react-hotkeys-hook';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
import Bookmarks from '../pages/bookmarks'; import Bookmarks from '../pages/bookmarks';
@ -12,6 +11,7 @@ import Public from '../pages/public';
import Search from '../pages/search'; import Search from '../pages/search';
import Trending from '../pages/trending'; import Trending from '../pages/trending';
import states from '../utils/states'; import states from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';
function Columns() { function Columns() {

View file

@ -1,8 +1,7 @@
import { useHotkeys } from 'react-hotkeys-hook';
import openCompose from '../utils/open-compose'; import openCompose from '../utils/open-compose';
import openOSK from '../utils/open-osk'; import openOSK from '../utils/open-osk';
import states from '../utils/states'; import states from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import Icon from './icon'; import Icon from './icon';

View file

@ -5,7 +5,6 @@ import { MenuItem } from '@szhsin/react-menu';
import { deepEqual } from 'fast-equals'; import { deepEqual } from 'fast-equals';
import { forwardRef } from 'preact/compat'; import { forwardRef } from 'preact/compat';
import { useEffect, useMemo, useRef, useState } from 'preact/hooks'; import { useEffect, useMemo, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import stringLength from 'string-length'; import stringLength from 'string-length';
import { uid } from 'uid/single'; import { uid } from 'uid/single';
import { useDebouncedCallback, useThrottledCallback } from 'use-debounce'; import { useDebouncedCallback, useThrottledCallback } from 'use-debounce';
@ -33,6 +32,7 @@ import {
} from '../utils/store-utils'; } from '../utils/store-utils';
import supports from '../utils/supports'; import supports from '../utils/supports';
import useCloseWatcher from '../utils/useCloseWatcher'; import useCloseWatcher from '../utils/useCloseWatcher';
import useHotkeys from '../utils/useHotkeys';
import useInterval from '../utils/useInterval'; import useInterval from '../utils/useInterval';
import visibilityIconsMap from '../utils/visibility-icons-map'; import visibilityIconsMap from '../utils/visibility-icons-map';

View file

@ -1,10 +1,10 @@
import './keyboard-shortcuts-help.css'; import './keyboard-shortcuts-help.css';
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { useHotkeys } from 'react-hotkeys-hook';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
import states from '../utils/states'; import states from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import Icon from './icon'; import Icon from './icon';
import Modal from './modal'; import Modal from './modal';

View file

@ -7,11 +7,11 @@ import {
useRef, useRef,
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { oklab2rgb, rgb2oklab } from '../utils/color-utils'; import { oklab2rgb, rgb2oklab } from '../utils/color-utils';
import showToast from '../utils/show-toast'; import showToast from '../utils/show-toast';
import states from '../utils/states'; import states from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import Icon from './icon'; import Icon from './icon';
import Link from './link'; import Link from './link';

View file

@ -2,9 +2,9 @@ import './modal.css';
import { createPortal } from 'preact/compat'; import { createPortal } from 'preact/compat';
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import useCloseWatcher from '../utils/useCloseWatcher'; import useCloseWatcher from '../utils/useCloseWatcher';
import useHotkeys from '../utils/useHotkeys';
const $modalContainer = document.getElementById('modal-container'); const $modalContainer = document.getElementById('modal-container');

View file

@ -2,7 +2,8 @@ import './search-command.css';
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { useRef, useState } from 'preact/hooks'; import { useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import useHotkeys from '../utils/useHotkeys';
import SearchForm from './search-form'; import SearchForm from './search-form';

View file

@ -3,7 +3,6 @@ import './shortcuts.css';
import { MenuDivider } from '@szhsin/react-menu'; import { MenuDivider } from '@szhsin/react-menu';
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { useRef, useState } from 'preact/hooks'; import { useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
@ -11,6 +10,7 @@ import { SHORTCUTS_META } from '../components/shortcuts-settings';
import { api } from '../utils/api'; import { api } from '../utils/api';
import { getLists } from '../utils/lists'; import { getLists } from '../utils/lists';
import states from '../utils/states'; import states from '../utils/states';
import useHotkeys from '../utils/useHotkeys';
import AsyncText from './AsyncText'; import AsyncText from './AsyncText';
import Icon from './icon'; import Icon from './icon';

View file

@ -21,7 +21,6 @@ import {
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import punycode from 'punycode'; import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { useLongPress } from 'use-long-press'; import { useLongPress } from 'use-long-press';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
@ -56,6 +55,7 @@ import states, { getStatus, saveStatus, statusKey } from '../utils/states';
import statusPeek from '../utils/status-peek'; import statusPeek from '../utils/status-peek';
import store from '../utils/store'; import store from '../utils/store';
import unfurlMastodonLink from '../utils/unfurl-link'; import unfurlMastodonLink from '../utils/unfurl-link';
import useHotkeys from '../utils/useHotkeys';
import useTruncated from '../utils/useTruncated'; import useTruncated from '../utils/useTruncated';
import visibilityIconsMap from '../utils/visibility-icons-map'; import visibilityIconsMap from '../utils/visibility-icons-map';

View file

@ -6,7 +6,6 @@ import {
useRef, useRef,
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { InView } from 'react-intersection-observer'; import { InView } from 'react-intersection-observer';
import { useDebouncedCallback } from 'use-debounce'; import { useDebouncedCallback } from 'use-debounce';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
@ -17,6 +16,7 @@ import states, { statusKey } from '../utils/states';
import statusPeek from '../utils/status-peek'; import statusPeek from '../utils/status-peek';
import { isMediaFirstInstance } from '../utils/store-utils'; import { isMediaFirstInstance } from '../utils/store-utils';
import { groupBoosts, groupContext } from '../utils/timeline-utils'; import { groupBoosts, groupContext } from '../utils/timeline-utils';
import useHotkeys from '../utils/useHotkeys';
import useInterval from '../utils/useInterval'; import useInterval from '../utils/useInterval';
import usePageVisibility from '../utils/usePageVisibility'; import usePageVisibility from '../utils/usePageVisibility';
import useScroll from '../utils/useScroll'; import useScroll from '../utils/useScroll';

View file

@ -14,7 +14,6 @@ import {
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import punycode from 'punycode'; import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { useSearchParams } from 'react-router-dom'; import { useSearchParams } from 'react-router-dom';
import { uid } from 'uid/single'; import { uid } from 'uid/single';
@ -42,6 +41,7 @@ import statusPeek from '../utils/status-peek';
import store from '../utils/store'; import store from '../utils/store';
import { getCurrentAccountNS } from '../utils/store-utils'; import { getCurrentAccountNS } from '../utils/store-utils';
import { assignFollowedTags } from '../utils/timeline-utils'; import { assignFollowedTags } from '../utils/timeline-utils';
import useHotkeys from '../utils/useHotkeys';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';
const FILTER_CONTEXT = 'home'; const FILTER_CONTEXT = 'home';

View file

@ -3,7 +3,6 @@ import './notifications.css';
import { Fragment } from 'preact'; import { Fragment } from 'preact';
import { memo } from 'preact/compat'; import { memo } from 'preact/compat';
import { useCallback, useEffect, useRef, useState } from 'preact/hooks'; import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { InView } from 'react-intersection-observer'; import { InView } from 'react-intersection-observer';
import { useSearchParams } from 'react-router-dom'; import { useSearchParams } from 'react-router-dom';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
@ -29,6 +28,7 @@ import showToast from '../utils/show-toast';
import states, { saveStatus } from '../utils/states'; import states, { saveStatus } from '../utils/states';
import { getCurrentInstance } from '../utils/store-utils'; import { getCurrentInstance } from '../utils/store-utils';
import supports from '../utils/supports'; import supports from '../utils/supports';
import useHotkeys from '../utils/useHotkeys';
import usePageVisibility from '../utils/usePageVisibility'; import usePageVisibility from '../utils/usePageVisibility';
import useScroll from '../utils/useScroll'; import useScroll from '../utils/useScroll';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';

View file

@ -2,7 +2,6 @@ import './search.css';
import { useAutoAnimate } from '@formkit/auto-animate/preact'; import { useAutoAnimate } from '@formkit/auto-animate/preact';
import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks'; import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';
import { InView } from 'react-intersection-observer'; import { InView } from 'react-intersection-observer';
import { useParams, useSearchParams } from 'react-router-dom'; import { useParams, useSearchParams } from 'react-router-dom';
@ -16,6 +15,7 @@ import Status from '../components/status';
import { api } from '../utils/api'; import { api } from '../utils/api';
import { fetchRelationships } from '../utils/relationships'; import { fetchRelationships } from '../utils/relationships';
import shortenNumber from '../utils/shorten-number'; import shortenNumber from '../utils/shorten-number';
import useHotkeys from '../utils/useHotkeys';
import usePageVisibility from '../utils/usePageVisibility'; import usePageVisibility from '../utils/usePageVisibility';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';

View file

@ -13,7 +13,6 @@ import {
useState, useState,
} from 'preact/hooks'; } from 'preact/hooks';
import punycode from 'punycode'; import punycode from 'punycode';
import { useHotkeys } from 'react-hotkeys-hook';
import { InView } from 'react-intersection-observer'; import { InView } from 'react-intersection-observer';
import { matchPath, useSearchParams } from 'react-router-dom'; import { matchPath, useSearchParams } from 'react-router-dom';
import { useSnapshot } from 'valtio'; import { useSnapshot } from 'valtio';
@ -38,6 +37,7 @@ import states, {
} from '../utils/states'; } from '../utils/states';
import statusPeek from '../utils/status-peek'; import statusPeek from '../utils/status-peek';
import { getCurrentAccount } from '../utils/store-utils'; import { getCurrentAccount } from '../utils/store-utils';
import useHotkeys from '../utils/useHotkeys';
import useScroll from '../utils/useScroll'; import useScroll from '../utils/useScroll';
import useTitle from '../utils/useTitle'; import useTitle from '../utils/useTitle';

16
src/utils/useHotkeys.js Normal file
View file

@ -0,0 +1,16 @@
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,
);
}