fix: determine os type from useOs hook

This commit is contained in:
luckrnx09
2024-05-25 21:35:10 +08:00
parent ab86247c8c
commit d02aa78def
2 changed files with 6 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
import { t, Trans } from "@lingui/macro"
import { Box, Center, Kbd, TextInput } from "@mantine/core"
import { useOs } from "@mantine/hooks"
import { Spotlight, spotlight, type SpotlightActionData } from "@mantine/spotlight"
import { redirectToFeed } from "app/redirect/thunks"
import { useAppDispatch } from "app/store"
@@ -12,13 +13,9 @@ export interface TreeSearchProps {
feeds: Subscription[]
}
function isMacOS() {
return navigator.platform.toUpperCase().includes("MAC")
}
export function TreeSearch(props: TreeSearchProps) {
const dispatch = useAppDispatch()
const isMacOS = useOs() === "macos"
const actions: SpotlightActionData[] = props.feeds
.map(f => ({
id: `${f.id}`,
@@ -31,7 +28,7 @@ export function TreeSearch(props: TreeSearchProps) {
const searchIcon = <TbSearch size={18} />
const rightSection = (
<Center style={{ cursor: "pointer" }} onClick={() => spotlight.open()}>
<Kbd>{isMacOS() ? "Cmd" : "Ctrl"}</Kbd>
<Kbd>{isMacOS ? "Cmd" : "Ctrl"}</Kbd>
<Box mx={5}>+</Box>
<Kbd>K</Kbd>
</Center>