diff --git a/apps/renderer/src/hooks/biz/useEntryActions.tsx b/apps/renderer/src/hooks/biz/useEntryActions.tsx index 07ddae239..74ac4359a 100644 --- a/apps/renderer/src/hooks/biz/useEntryActions.tsx +++ b/apps/renderer/src/hooks/biz/useEntryActions.tsx @@ -173,11 +173,7 @@ export const useEntryActions = ({ } as CombinedEntryModel }, [entry, feed, inbox]) - const openTipModal = useTipModal({ - userId: populatedEntry?.feeds?.ownerUserId ?? undefined, - feedId: populatedEntry?.feeds?.id ?? undefined, - entryId: populatedEntry?.entries.id ?? undefined, - }) + const openTipModal = useTipModal() const showSourceContent = useShowSourceContent() const showSourceContentModal = useSourceContentModal() @@ -210,7 +206,13 @@ export const useEntryActions = ({ className: "i-mgc-power-outline", hide: isInbox || feed?.ownerUserId === whoami()?.id, onClick: () => { - nextFrame(openTipModal) + nextFrame(() => + openTipModal({ + userId: populatedEntry?.feeds?.ownerUserId ?? undefined, + feedId: populatedEntry?.feeds?.id ?? undefined, + entryId: populatedEntry?.entries.id ?? undefined, + }), + ) }, }, { diff --git a/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx b/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx index 2826aa313..d7914300c 100644 --- a/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx +++ b/apps/renderer/src/modules/entry-content/components/SupportCreator.tsx @@ -21,11 +21,7 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => { const feed = useFeedById(entry?.feedId) const { data: feedBoosters } = useFeedBoostersQuery(entry?.feedId) - const openTipModal = useTipModal({ - userId: feed?.ownerUserId ?? undefined, - feedId: entry?.feedId, - entryId, - }) + const openTipModal = useTipModal() const openBoostModal = useBoostModal() const isMyOwnedFeed = feed?.ownerUserId === useWhoami()?.id @@ -60,7 +56,15 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => {
{!isMyOwnedFeed && ( - diff --git a/apps/renderer/src/modules/wallet/hooks.ts b/apps/renderer/src/modules/wallet/hooks.ts index 337f7a43c..66d764324 100644 --- a/apps/renderer/src/modules/wallet/hooks.ts +++ b/apps/renderer/src/modules/wallet/hooks.ts @@ -6,27 +6,22 @@ import { useModalStack } from "~/components/ui/modal/stacked/hooks" import { TipModalContent } from "./tip-modal" -export const useTipModal = ({ - userId, - feedId, - entryId, -}: { - userId?: string - feedId?: string - entryId?: string -}) => { +export const useTipModal = () => { const { present } = useModalStack() const { t } = useTranslation() - return useCallback(() => { - if (!feedId || !entryId) { - // this should not happen unless there is a bug in the code - toast.error("Invalid feed id or entry id") - return - } - window.analytics?.capture("tip_modal_opened", { entryId }) - present({ - title: t("tip_modal.tip_title"), - content: () => createElement(TipModalContent, { userId, feedId, entryId }), - }) - }, [present, userId, feedId, entryId]) + return useCallback( + ({ userId, feedId, entryId }: { userId?: string; 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") + return + } + window.analytics?.capture("tip_modal_opened", { entryId }) + present({ + title: t("tip_modal.tip_title"), + content: () => createElement(TipModalContent, { userId, feedId, entryId }), + }) + }, + [present, t], + ) }