Skip to content

Commit

Permalink
fix(wallet): entry -> feed
Browse files Browse the repository at this point in the history
  • Loading branch information
songkeys committed Jun 27, 2024
1 parent 73826b5 commit e358cef
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 42 deletions.
52 changes: 23 additions & 29 deletions src/renderer/src/hono.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ declare const routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
$post: {
input: {
json: {
userId: string;
amount: string;
entryId?: string | undefined;
userId?: string | undefined;
feedId?: string | undefined;
};
};
output: {
Expand All @@ -31,7 +31,7 @@ declare const routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
hash?: string | undefined;
fromUserId?: string | undefined;
toUserId?: string | undefined;
toEntryId?: string | undefined;
toFeedId?: string | undefined;
fromOrToUserId?: string | undefined;
createdAfter?: string | undefined;
};
Expand All @@ -45,46 +45,40 @@ declare const routes: hono_hono_base.HonoBase<hono_types.BlankEnv, {
hash: string;
fromUserId: string | null;
toUserId: string | null;
toEntryId: string | null;
toFeedId: string | null;
comment: string | null;
fromUser?: {
fromUser: {
name: string | null;
id: string;
email: string;
emailVerified: Date | null;
emailVerified: string | null;
image: string | null;
handle: string | null;
} | undefined;
toUser?: {
} | null;
toUser: {
name: string | null;
id: string;
email: string;
emailVerified: Date | null;
emailVerified: string | null;
image: string | null;
handle: string | null;
} | undefined;
toEntry?: {
} | null;
toFeed: {
description: string | null;
title: string | null;
content: string | null;
id: string;
author: string | null;
url: string | null;
feedId: string;
guid: string;
authorUrl: string | null;
authorAvatar: string | null;
changedAt: string;
publishedAt: string;
images: string[] | null;
categories: string[] | null;
enclosures?: {
url: string;
length?: number | undefined;
type?: string | undefined;
title?: string | undefined;
}[] | null | undefined;
} | undefined;
image: string | null;
url: string;
siteUrl: string | null;
checkedAt: string;
nextCheckAt: string;
lastModifiedHeader: string | null;
etagHeader: string | null;
ttl: number | null;
errorMessage: string | null;
errorAt: string | null;
ownerUserId: string | null;
} | null;
}[];
};
outputFormat: "json";
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const useEntryActions = ({
// comment out L119-122 to work ⬇️
const openTipModal = useTipModal({
userId: entry?.feeds.ownerUserId ?? undefined,
entryId: entry?.entries.id ?? undefined,
feedId: entry?.feeds.id ?? undefined,
})

const collect = useCollect(entry)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const TransactionsSection = () => {
<TableHead size="sm" className="uppercase">Amount</TableHead>
<TableHead size="sm" className="uppercase">From</TableHead>
<TableHead size="sm" className="uppercase">To</TableHead>
<TableHead size="sm" className="uppercase">Entry</TableHead>
<TableHead size="sm" className="uppercase">Feed</TableHead>
<TableHead size="sm" className="uppercase">Date</TableHead>
</TableRow>
</TableHeader>
Expand All @@ -45,7 +45,7 @@ export const TransactionsSection = () => {
<TableCell align="center" size="sm"><Balance>{row.powerToken}</Balance></TableCell>
<TableCell align="center" size="sm"><UserRenderer user={row.fromUser} /></TableCell>
<TableCell align="center" size="sm"><UserRenderer user={row.toUser} /></TableCell>
<TableCell align="center" size="sm"><EntryRenderer entry={row.toEntry} /></TableCell>
<TableCell align="center" size="sm"><FeedRenderer feed={row.toFeed} /></TableCell>
<TableCell align="center" size="sm">{dayjs(row.createdAt).fromNow()}</TableCell>
</TableRow>
),
Expand Down Expand Up @@ -87,8 +87,8 @@ const UserRenderer = ({ user }: { user?: NonNullable<ReturnType<typeof useWallet
)
}

const EntryRenderer = ({ entry }: { entry: NonNullable<ReturnType<typeof useWalletTransactions>["data"]>[number]["toEntry"] }) => (
const FeedRenderer = ({ feed }: { feed: NonNullable<ReturnType<typeof useWalletTransactions>["data"]>[number]["toFeed"] }) => (
<div className="center line-clamp-1 truncate">
{entry?.title ?? "-"}
{feed?.title ?? "-"}
</div>
)
6 changes: 3 additions & 3 deletions src/renderer/src/modules/wallet/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { toast } from "sonner"

import { TipModalContent } from "./tip-modal"

export const useTipModal = ({ userId, entryId }: { userId?: string, entryId?: string }) => {
export const useTipModal = ({ userId, feedId }: { userId?: string, feedId?: string }) => {
const { present } = useModalStack()

return useCallback(() => {
Expand All @@ -16,7 +16,7 @@ export const useTipModal = ({ userId, entryId }: { userId?: string, entryId?: st

present({
title: "Tip",
content: () => createElement(TipModalContent, { userId, entryId }),
content: () => createElement(TipModalContent, { userId, feedId }),
})
}, [present, userId, entryId])
}, [present, userId, feedId])
}
8 changes: 4 additions & 4 deletions src/renderer/src/modules/wallet/tip-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import type { FC } from "react"

export const TipModalContent: FC<{
userId: string
entryId?: string
}> = ({ userId, entryId }) => {
const transationsQuery = useWalletTransactions({ toUserId: userId, toEntryId: entryId })
feedId?: string
}> = ({ userId, feedId }) => {
const transationsQuery = useWalletTransactions({ toUserId: userId, toFeedId: feedId })

const tipMutation = useWalletTipMutation()

Expand All @@ -30,7 +30,7 @@ export const TipModalContent: FC<{
<StyledButton
disabled={tipMutation.isSuccess || tipMutation.isPending}
isLoading={tipMutation.isPending}
onClick={() => tipMutation.mutate({ userId, entryId, amount: "0" })}
onClick={() => tipMutation.mutate({ userId, feedId, amount: "0" })}
variant={tipMutation.isSuccess ? "plain" : "primary"}
>
{tipMutation.isSuccess && (
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/queries/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const useClaimWalletDailyRewardMutation = () => useMutation({

export const useWalletTipMutation = () => useMutation({
mutationKey: ["walletTip"],
mutationFn: (data: { userId: string, entryId?: string, amount: string }) =>
mutationFn: (data: Parameters<typeof apiClient.wallets.transactions.tip.$post>[0]["json"]) =>
apiClient.wallets.transactions.tip.$post({ json: data }),
async onError(err) {
toast.error(await getFetchErrorMessage(err))
Expand Down

0 comments on commit e358cef

Please sign in to comment.