Skip to content

Commit ffca130

Browse files
committed
fix: commands in action responsive
Signed-off-by: Innei <tukon479@gmail.com>
1 parent d0bf0fb commit ffca130

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

apps/renderer/src/hooks/biz/useEntryActions.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { whoami } from "~/atoms/user"
1616
import { shortcuts } from "~/constants/shortcuts"
1717
import { tipcClient } from "~/lib/client"
1818
import { COMMAND_ID } from "~/modules/command/commands/id"
19-
import { getCommand, useRunCommandFn } from "~/modules/command/hooks/use-command"
19+
import { getCommand, useCommands, useRunCommandFn } from "~/modules/command/hooks/use-command"
2020
import type { FollowCommandId } from "~/modules/command/types"
2121
import { useEntry } from "~/store/entry"
2222
import { useFeedById } from "~/store/feed"
@@ -87,8 +87,11 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
8787
const isShowAISummary = useShowAISummary()
8888
const isShowAITranslation = useShowAITranslation()
8989

90+
const commands = useCommands()
91+
9092
const runCmdFn = useRunCommandFn()
9193
const actionConfigs = useMemo(() => {
94+
void commands
9295
if (!entryId) return []
9396
return [
9497
{
@@ -222,6 +225,8 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee
222225
isShowSourceContent,
223226
runCmdFn,
224227
view,
228+
229+
commands,
225230
])
226231

227232
return actionConfigs

apps/renderer/src/modules/command/hooks/use-command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const getCommand = <T extends FollowCommandId>(id: T) => {
1111
return id in commands ? commands[id] : null
1212
}
1313

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

0 commit comments

Comments
 (0)