diff --git a/src/hono.ts b/src/hono.ts index 7f057c5b0..cf7d1d8fc 100644 --- a/src/hono.ts +++ b/src/hono.ts @@ -2297,6 +2297,22 @@ declare const transactions: drizzle_orm_pg_core.PgTableWithColumns<{ baseColumn: never; generated: undefined; }, {}, {}>; + toEntryId: drizzle_orm_pg_core.PgColumn<{ + name: "to_entry_id"; + tableName: "transactions"; + dataType: "string"; + columnType: "PgText"; + data: string; + driverParam: string; + notNull: false; + hasDefault: false; + isPrimaryKey: false; + isAutoincrement: false; + hasRuntimeDefault: false; + enumValues: [string, ...string[]]; + baseColumn: never; + generated: undefined; + }, {}, {}>; powerToken: drizzle_orm_pg_core.PgColumn<{ name: "power_token"; tableName: "transactions"; @@ -2354,6 +2370,7 @@ declare const transactionsOpenAPISchema: zod.ZodObject<{ fromUserId: zod.ZodNullable; toUserId: zod.ZodNullable; toFeedId: zod.ZodNullable; + toEntryId: zod.ZodNullable; powerToken: zod.ZodString; createdAt: zod.ZodString; comment: zod.ZodNullable; @@ -2364,6 +2381,7 @@ declare const transactionsOpenAPISchema: zod.ZodObject<{ fromUserId: string | null; toUserId: string | null; toFeedId: string | null; + toEntryId: string | null; powerToken: string; comment: string | null; }, { @@ -2373,6 +2391,7 @@ declare const transactionsOpenAPISchema: zod.ZodObject<{ fromUserId: string | null; toUserId: string | null; toFeedId: string | null; + toEntryId: string | null; powerToken: string; comment: string | null; }>; @@ -2535,9 +2554,8 @@ declare const _routes: hono_hono_base.HonoBase { const { present } = useModalStack() return useCallback(() => { - if (!userId && !feedId) { + if (!feedId || !entryId) { // this should not happen unless there is a bug in the code - toast.error("Invalid user id or feed id") + toast.error("Invalid feed id or entry id") return } window.posthog?.capture("tip_modal_opened", { feedId }) present({ title: "Tip Power", - content: () => createElement(TipModalContent, { userId, feedId }), + content: () => createElement(TipModalContent, { userId, feedId, entryId }), }) - }, [present, userId, feedId]) + }, [present, userId, feedId, entryId]) } diff --git a/src/renderer/src/modules/wallet/tip-modal.tsx b/src/renderer/src/modules/wallet/tip-modal.tsx index 1dd25f58a..f5faf04e0 100644 --- a/src/renderer/src/modules/wallet/tip-modal.tsx +++ b/src/renderer/src/modules/wallet/tip-modal.tsx @@ -10,9 +10,8 @@ import { nextFrame } from "@renderer/lib/dom" import { useWallet, useWalletTipMutation, - useWalletTransactions, } from "@renderer/queries/wallet" -import { from, toNumber } from "dnum" +import { from } from "dnum" import type { FC } from "react" import { useState } from "react" @@ -36,7 +35,8 @@ const Loading = () => ( export const TipModalContent: FC<{ userId?: string - feedId?: string + feedId: string + entryId: string }> = (props) => { const myWallet = useMyWallet() @@ -47,31 +47,19 @@ export const TipModalContent: FC<{ } const TipModalContent_: FC<{ userId?: string - feedId?: string -}> = ({ userId, feedId }) => { + feedId: string + entryId: string +}> = ({ userId, feedId, entryId }) => { const myWallet = useMyWallet() const myWalletData = myWallet.data?.[0] const dPowerBigInt = BigInt(myWalletData?.dailyPowerToken ?? 0) const cPowerBigInt = BigInt(myWalletData?.cashablePowerToken ?? 0) const balanceBigInt = cPowerBigInt + dPowerBigInt - const balanceNumber = toNumber(from(balanceBigInt, 18), { - digits: 2, - trailingZeros: true, - }) - - const transactionsQuery = useWalletTransactions({ - toUserId: userId, - toFeedId: feedId, - }) const tipMutation = useWalletTipMutation() - const [amount, setAmount] = useState( - DEFAULT_RECOMMENDED_TIP > balanceNumber ? - balanceNumber : - DEFAULT_RECOMMENDED_TIP, - ) + const [amount, setAmount] = useState<1 | 2>(DEFAULT_RECOMMENDED_TIP) const amountBigInt = from(amount, 18)[0] @@ -86,7 +74,7 @@ const TipModalContent_: FC<{ feedId, }) - if (transactionsQuery.isPending || myWallet.isPending) { + if (myWallet.isPending) { return } @@ -176,7 +164,7 @@ const TipModalContent_: FC<{ setAmount(Number(value))} + onValueChange={(value) => setAmount(Number(value) as 1 | 2)} >
{ if (tipMutation.isPending) return tipMutation.mutate({ - userId, - feedId, - amount: amountBigInt.toString(), + entryId, + amount: amountBigInt.toString() as "1000000000000000000" | "2000000000000000000", }) }} variant={tipMutation.isSuccess ? "outline" : "primary"}