Skip to content

Commit

Permalink
fix: fill missing userId when open tip modal, close #2248
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Dec 26, 2024
1 parent 1a306a5 commit 53ad291
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apps/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/renderer/src/modules/command/commands/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand Down
10 changes: 9 additions & 1 deletion apps/renderer/src/modules/wallet/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions apps/renderer/src/modules/wallet/tip-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const Loading = () => (
)

export const TipModalContent: FC<{
userId?: string
userId?: string | null
feedId: string
entryId: string
}> = (props) => {
Expand All @@ -43,7 +43,7 @@ export const TipModalContent: FC<{
return <TipModalContent_ {...props} />
}
const TipModalContent_: FC<{
userId?: string
userId?: string | null
feedId: string
entryId: string
}> = ({ userId, feedId, entryId }) => {
Expand Down

0 comments on commit 53ad291

Please sign in to comment.