refs #4653 Add account switching shortcut

This commit is contained in:
AkiraFukushima 2023-12-22 00:35:54 +09:00
parent 49f0cd2937
commit 5e7cbbb0a1
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
3 changed files with 16 additions and 0 deletions

View File

@ -25,6 +25,7 @@
"flowbite-react": "^0.7.0",
"megalodon": "^9.1.1",
"react-blurhash": "^0.3.0",
"react-hotkeys-hook": "^4.4.1",
"react-icons": "^4.11.0",
"react-intl": "^6.5.1",
"react-virtuoso": "^4.6.2",

View File

@ -9,6 +9,7 @@ import { FormattedMessage, useIntl } from 'react-intl'
import generateNotification from '@/utils/notification'
import generator, { Entity, WebSocketInterface } from 'megalodon'
import { Context } from '@/utils/i18n'
import { useHotkeys } from 'react-hotkeys-hook'
type LayoutProps = {
children: React.ReactNode
@ -24,6 +25,15 @@ export default function Layout({ children }: LayoutProps) {
const { formatMessage } = useIntl()
const streamings = useRef<Array<WebSocketInterface>>([])
for (let i = 1; i < 9; i++) {
useHotkeys(`ctrl+${i}`, () => {
const acct = accounts[i - 1]
if (acct && acct.id) {
router.push(`/accounts/${acct.id}`)
}
})
}
useEffect(() => {
loadSettings()
const fn = async () => {

View File

@ -7095,6 +7095,11 @@ react-dom@^18.2.0:
loose-envify "^1.1.0"
scheduler "^0.23.0"
react-hotkeys-hook@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/react-hotkeys-hook/-/react-hotkeys-hook-4.4.1.tgz#1f7a7a1c9c21d4fa3280bf340fcca8fd77d81994"
integrity sha512-sClBMBioFEgFGYLTWWRKvhxcCx1DRznd+wkFHwQZspnRBkHTgruKIHptlK/U/2DPX8BhHoRGzpMVWUXMmdZlmw==
react-icons@^4.11.0:
version "4.12.0"
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.12.0.tgz#54806159a966961bfd5cdb26e492f4dafd6a8d78"