Skip to content

Commit

Permalink
Test upgrade react-hotkeys-hook for the keys fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Apr 12, 2024
1 parent 7fb56d9 commit 9285a0b
Show file tree
Hide file tree
Showing 18 changed files with 37 additions and 21 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"p-throttle": "~6.1.0",
"preact": "~10.20.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-quick-pinch-zoom": "~5.1.0",
"react-router-dom": "6.6.2",
Expand Down
2 changes: 1 addition & 1 deletion src/components/background-service.jsx
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/components/columns.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useHotkeys } from 'react-hotkeys-hook';
import { useSnapshot } from 'valtio';

import Bookmarks from '../pages/bookmarks';
Expand All @@ -12,6 +11,7 @@ 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() {
Expand Down
3 changes: 1 addition & 2 deletions src/components/compose-button.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
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';

Expand Down
2 changes: 1 addition & 1 deletion src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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';
Expand Down Expand Up @@ -33,6 +32,7 @@ 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';

Expand Down
2 changes: 1 addition & 1 deletion src/components/keyboard-shortcuts-help.jsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/components/media-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/components/modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
3 changes: 2 additions & 1 deletion src/components/search-command.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import './search-command.css';

import { memo } from 'preact/compat';
import { useRef, useState } from 'preact/hooks';
import { useHotkeys } from 'react-hotkeys-hook';

import useHotkeys from '../utils/useHotkeys';

import SearchForm from './search-form';

Expand Down
2 changes: 1 addition & 1 deletion src/components/shortcuts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ 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';

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';
Expand Down
2 changes: 1 addition & 1 deletion src/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ 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';

Expand Down Expand Up @@ -56,6 +55,7 @@ import states, { getStatus, saveStatus, statusKey } from '../utils/states';
import statusPeek from '../utils/status-peek';
import store from '../utils/store';
import unfurlMastodonLink from '../utils/unfurl-link';
import useHotkeys from '../utils/useHotkeys';
import useTruncated from '../utils/useTruncated';
import visibilityIconsMap from '../utils/visibility-icons-map';

Expand Down
2 changes: 1 addition & 1 deletion src/components/timeline.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ 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';
Expand All @@ -17,6 +16,7 @@ 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';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/catchup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ 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';

Expand Down Expand Up @@ -42,6 +41,7 @@ import statusPeek from '../utils/status-peek';
import store from '../utils/store';
import { 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';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/notifications.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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';
Expand All @@ -29,6 +28,7 @@ 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';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/search.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ 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';

Expand All @@ -16,6 +15,7 @@ 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';

Expand Down
2 changes: 1 addition & 1 deletion src/pages/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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';
Expand All @@ -38,6 +37,7 @@ 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';

Expand Down
16 changes: 16 additions & 0 deletions src/utils/useHotkeys.js
Original file line number Diff line number Diff line change
@@ -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,
);
}

0 comments on commit 9285a0b

Please sign in to comment.