Skip to content

Commit

Permalink
fix: commands in action responsive
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <tukon479@gmail.com>
  • Loading branch information
Innei committed Dec 16, 2024
1 parent d0bf0fb commit ffca130
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion apps/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { whoami } from "~/atoms/user"
import { shortcuts } from "~/constants/shortcuts"
import { tipcClient } from "~/lib/client"
import { COMMAND_ID } from "~/modules/command/commands/id"
import { getCommand, useRunCommandFn } from "~/modules/command/hooks/use-command"
import { getCommand, useCommands, useRunCommandFn } from "~/modules/command/hooks/use-command"
import type { FollowCommandId } from "~/modules/command/types"
import { useEntry } from "~/store/entry"
import { useFeedById } from "~/store/feed"
Expand Down Expand Up @@ -87,8 +87,11 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
const isShowAISummary = useShowAISummary()
const isShowAITranslation = useShowAITranslation()

const commands = useCommands()

const runCmdFn = useRunCommandFn()
const actionConfigs = useMemo(() => {
void commands
if (!entryId) return []
return [
{
Expand Down Expand Up @@ -222,6 +225,8 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
isShowSourceContent,
runCmdFn,
view,

commands,
])

return actionConfigs
Expand Down
1 change: 1 addition & 0 deletions apps/renderer/src/modules/command/hooks/use-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const getCommand = <T extends FollowCommandId>(id: T) => {
return id in commands ? commands[id] : null
}

export const useCommands = () => useAtomValue(CommandRegistry.atom)
export function useCommand<T extends FollowCommandId>(id: T): FollowCommandMap[T] | null {
const commands = useAtomValue(
useMemo(() => selectAtom(CommandRegistry.atom, (commands) => commands[id]), [id]),
Expand Down

0 comments on commit ffca130

Please sign in to comment.