From dac49f779a7abc0aca13f16c6a65313e7203df86 Mon Sep 17 00:00:00 2001 From: talksik Date: Sun, 20 Mar 2022 17:58:09 -0400 Subject: [PATCH] shortcut for starting seach --- .../src/pages/Home/conversations/index.tsx | 14 +--- .../desktop/src/pages/Home/header/index.tsx | 64 ++++++++++++------- 2 files changed, 43 insertions(+), 35 deletions(-) diff --git a/packages/desktop/src/pages/Home/conversations/index.tsx b/packages/desktop/src/pages/Home/conversations/index.tsx index e8f1b53..10d4333 100644 --- a/packages/desktop/src/pages/Home/conversations/index.tsx +++ b/packages/desktop/src/pages/Home/conversations/index.tsx @@ -1,9 +1,4 @@ -import { - Add, - CardGiftcardRounded, - ContactsRounded, - LinkRounded, -} from "@mui/icons-material"; +import { Add, LinkRounded } from "@mui/icons-material"; import { FaVolumeUp } from "react-icons/fa"; @@ -21,17 +16,10 @@ export default function Conversations() { <> {/* actions navbar */}
- - - - - - - diff --git a/packages/desktop/src/pages/Home/header/index.tsx b/packages/desktop/src/pages/Home/header/index.tsx index 1c3b89f..b31988c 100644 --- a/packages/desktop/src/pages/Home/header/index.tsx +++ b/packages/desktop/src/pages/Home/header/index.tsx @@ -3,13 +3,17 @@ import { Dropdown, Menu } from "antd"; import Logo, { LogoType } from "../../../components/Logo"; import { useRecoilState, useSetRecoilState } from "recoil"; +import { GlobalHotKeys } from "react-hotkeys"; import { STORE_ITEMS } from "../../../electron/constants"; import { useGetUserDetails } from "../../../controller/index"; +import { useRef } from "react"; export default function Header() { const { data: user, isLoading } = useGetUserDetails(); const [searchQuery, setSearchQuery] = useRecoilState($searchQuery); + const inputRef = useRef(null); + const setAuthTokens = useSetRecoilState($authTokens); if (isLoading) { @@ -29,30 +33,46 @@ export default function Header() { ); + // hot keys for selecting search + const handleSearch = () => { + if (inputRef?.current) { + inputRef?.current?.focus(); + setSearchQuery(""); + } + }; + + const keyMap = { START_SEARCH: "/" }; + const handlers = { START_SEARCH: handleSearch }; + return ( -
- - setSearchQuery(e.target.value)} - /> + <> + - +
+ + setSearchQuery(e.target.value)} + /> - - - cannot find - - - -
+ + + + + cannot find + + + +
+ ); }