From 53ad291820ccefc6badee8d3dc6af276c31c3cc6 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Thu, 26 Dec 2024 11:52:05 +0800 Subject: [PATCH] fix: fill missing userId when open tip modal, close #2248 --- apps/renderer/src/hooks/biz/useEntryActions.tsx | 4 +++- apps/renderer/src/modules/command/commands/types.ts | 2 +- apps/renderer/src/modules/wallet/hooks.ts | 10 +++++++++- apps/renderer/src/modules/wallet/tip-modal.tsx | 4 ++-- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/apps/renderer/src/hooks/biz/useEntryActions.tsx b/apps/renderer/src/hooks/biz/useEntryActions.tsx index a6332c666..58b020d82 100644 --- a/apps/renderer/src/hooks/biz/useEntryActions.tsx +++ b/apps/renderer/src/hooks/biz/useEntryActions.tsx @@ -117,7 +117,9 @@ export const useEntryActions = ({ entryId, view }: { entryId: string; view?: Fee }, { id: COMMAND_ID.entry.tip, - onClick: runCmdFn(COMMAND_ID.entry.tip, [{ entryId, feedId: feed?.id }]), + onClick: runCmdFn(COMMAND_ID.entry.tip, [ + { entryId, feedId: feed?.id, userId: feed?.ownerUserId }, + ]), hide: isInbox || feed?.ownerUserId === whoami()?.id, shortcut: shortcuts.entry.tip.key, }, diff --git a/apps/renderer/src/modules/command/commands/types.ts b/apps/renderer/src/modules/command/commands/types.ts index 26439c1ce..cbdc31838 100644 --- a/apps/renderer/src/modules/command/commands/types.ts +++ b/apps/renderer/src/modules/command/commands/types.ts @@ -7,7 +7,7 @@ import type { COMMAND_ID } from "./id" export type TipCommand = Command<{ id: typeof COMMAND_ID.entry.tip - fn: (data: { userId?: string; feedId?: string; entryId?: string }) => void + fn: (data: { userId?: string | null; feedId?: string; entryId?: string }) => void }> export type StarCommand = Command<{ diff --git a/apps/renderer/src/modules/wallet/hooks.ts b/apps/renderer/src/modules/wallet/hooks.ts index 66d764324..e8d5f1af9 100644 --- a/apps/renderer/src/modules/wallet/hooks.ts +++ b/apps/renderer/src/modules/wallet/hooks.ts @@ -10,7 +10,15 @@ export const useTipModal = () => { const { present } = useModalStack() const { t } = useTranslation() return useCallback( - ({ userId, feedId, entryId }: { userId?: string; feedId?: string; entryId?: string }) => { + ({ + userId, + feedId, + entryId, + }: { + userId?: string | null + feedId?: string + entryId?: string + }) => { if (!feedId || !entryId) { // this should not happen unless there is a bug in the code toast.error("Invalid feed id or entry id") diff --git a/apps/renderer/src/modules/wallet/tip-modal.tsx b/apps/renderer/src/modules/wallet/tip-modal.tsx index e93a1abb3..570417850 100644 --- a/apps/renderer/src/modules/wallet/tip-modal.tsx +++ b/apps/renderer/src/modules/wallet/tip-modal.tsx @@ -31,7 +31,7 @@ const Loading = () => ( ) export const TipModalContent: FC<{ - userId?: string + userId?: string | null feedId: string entryId: string }> = (props) => { @@ -43,7 +43,7 @@ export const TipModalContent: FC<{ return } const TipModalContent_: FC<{ - userId?: string + userId?: string | null feedId: string entryId: string }> = ({ userId, feedId, entryId }) => {