From 0a98f371a837ba3b7e4bc086f6352af6033c2081 Mon Sep 17 00:00:00 2001 From: Innei Date: Sun, 20 Oct 2024 16:09:46 +0800 Subject: [PATCH 1/9] fix: timeline tabs styles Signed-off-by: Innei --- .../entry-column/layouts/EntryListHeader.tsx | 119 ++++++++++-------- 1 file changed, 64 insertions(+), 55 deletions(-) diff --git a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx index 3a6d527403..c81e37f6f8 100644 --- a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx +++ b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx @@ -40,7 +40,7 @@ export const EntryListHeader: FC<{ const unreadOnly = useGeneralSettingKey("unreadOnly") - const { feedId, entryId, view, listId, inboxId } = routerParams + const { feedId, entryId, view, listId } = routerParams const headerTitle = useFeedHeaderTitle() const os = getOS() @@ -48,16 +48,6 @@ export const EntryListHeader: FC<{ const titleAtBottom = IN_ELECTRON && os === "macOS" const isInCollectionList = feedId === FEED_COLLECTION_LIST - const listsData = useSubscriptionStore((state) => - state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s), - ) - const inboxData = useSubscriptionStore((state) => - state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s), - ) - const hasData = listsData.length > 0 || inboxData.length > 0 - - const timeline = listId || inboxId || "" - const titleInfo = !!headerTitle && (
@@ -82,7 +72,6 @@ export const EntryListHeader: FC<{ const isList = !!listId const containerRef = React.useRef(null) - const navigate = useNavigateEntry() return (
} - {isOnline ? ( - feed?.ownerUserId === user?.id && + {isOnline && + (feed?.ownerUserId === user?.id && isBizId(routerParams.feedId!) && feed?.type === "feed" ? ( - ) - ) : null} + ))} {!isList && ( <>
{titleAtBottom && titleInfo} - {hasData && ( - { - if (!val) { - navigate({ - feedId: null, - entryId: null, - view, - }) - } - }} - > - - Yours - {listsData.map((s) => ( - - - - ))} - {inboxData.map((s) => ( - - - - ))} - - - )} +
) } @@ -326,3 +276,62 @@ const AppendTaildingDivider = ({ children }: { children: React.ReactNode }) => ( )} ) + +const TimelineTabs = () => { + const routerParams = useRouteParams() + const { view, listId, inboxId } = routerParams + + const listsData = useSubscriptionStore((state) => + state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s), + ) + const inboxData = useSubscriptionStore((state) => + state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s), + ) + const hasData = listsData.length > 0 || inboxData.length > 0 + + const timeline = listId || inboxId || "" + + const navigate = useNavigateEntry() + if (!hasData) return null + return ( + { + if (!val) { + navigate({ + feedId: null, + entryId: null, + view, + }) + } + }} + > + + + Yours + + {listsData.map((s) => ( + + + + ))} + {inboxData.map((s) => ( + + + + ))} + + + ) +} From 847c317bb4fe4258b7eed240e5e6422bf273838d Mon Sep 17 00:00:00 2001 From: Innei Date: Sun, 20 Oct 2024 17:31:01 +0800 Subject: [PATCH 2/9] fix: tab rounded variant Signed-off-by: Innei --- apps/renderer/src/components/ui/tabs.tsx | 99 ++++++++++--------- .../entry-column/layouts/EntryListHeader.tsx | 66 +------------ .../entry-column/layouts/TimelineTabs.tsx | 64 ++++++++++++ 3 files changed, 118 insertions(+), 111 deletions(-) create mode 100644 apps/renderer/src/modules/entry-column/layouts/TimelineTabs.tsx diff --git a/apps/renderer/src/components/ui/tabs.tsx b/apps/renderer/src/components/ui/tabs.tsx index 529b222850..ee6e212a9f 100644 --- a/apps/renderer/src/components/ui/tabs.tsx +++ b/apps/renderer/src/components/ui/tabs.tsx @@ -56,8 +56,7 @@ const tabsTriggerVariants = cva("", { variant: { default: "py-1.5 border-b-2 border-transparent data-[state=active]:text-accent dark:data-[state=active]:text-theme-accent-500", - rounded: - "py-1 rounded-sm data-[state=active]:bg-theme-accent-300 dark:data-[state=active]:bg-theme-accent-800 data-[state=active]:shadow-sm", + rounded: "!py-1 !px-3 bg-transparent", }, }, defaultVariants: { @@ -68,58 +67,64 @@ const tabsTriggerVariants = cva("", { export interface TabsTriggerProps extends React.ComponentPropsWithoutRef, VariantProps {} -const TabsTrigger = React.forwardRef< - React.ElementRef, - TabsTriggerProps ->(({ className, variant, children, ...props }, ref) => { - const triggerRef = React.useRef(null) - React.useImperativeHandle(ref, () => triggerRef.current!, [ref]) +const TabsTrigger = React.forwardRef( + ({ className, variant, children, ...props }, ref) => { + const triggerRef = React.useRef(null) + React.useImperativeHandle(ref, () => triggerRef.current!, []) - const [isSelect, setIsSelect] = React.useState(false) - const id = React.useContext(TabsIdContext) - const layoutId = `tab-selected-underline-${id}` - React.useLayoutEffect(() => { - if (!triggerRef.current) return + const [isSelect, setIsSelect] = React.useState(false) + const id = React.useContext(TabsIdContext) + const layoutId = `tab-selected-underline-${id}` + React.useLayoutEffect(() => { + if (!triggerRef.current) return - const trigger = triggerRef.current as HTMLElement + const trigger = triggerRef.current as HTMLElement - const isSelect = trigger.dataset.state === "active" - setIsSelect(isSelect) - const ob = new MutationObserver(() => { const isSelect = trigger.dataset.state === "active" setIsSelect(isSelect) - }) - ob.observe(trigger, { - attributes: true, - attributeFilter: ["data-state"], - }) + const ob = new MutationObserver(() => { + const isSelect = trigger.dataset.state === "active" + setIsSelect(isSelect) + }) + ob.observe(trigger, { + attributes: true, + attributeFilter: ["data-state"], + }) - return () => { - ob.disconnect() - } - }, []) + return () => { + ob.disconnect() + } + }, []) - return ( - - {children} - {isSelect && ( - - )} - - ) -}) + return ( + + {children} + {isSelect && ( + + )} + + ) + }, +) TabsTrigger.displayName = TabsPrimitive.Trigger.displayName const TabsContent = React.forwardRef< diff --git a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx index c81e37f6f8..3944c2e9e7 100644 --- a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx +++ b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx @@ -10,11 +10,9 @@ import { ImpressionView } from "~/components/common/ImpressionTracker" import { ActionButton } from "~/components/ui/button" import { DividerVertical } from "~/components/ui/divider" import { RotatingRefreshIcon } from "~/components/ui/loading" -import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs" import { EllipsisHorizontalTextWithTooltip } from "~/components/ui/typography" import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING, views } from "~/constants" import { shortcuts } from "~/constants/shortcuts" -import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" import { useRouteParams } from "~/hooks/biz/useRouteParams" import { useIsOnline } from "~/hooks/common" import { stopPropagation } from "~/lib/dom" @@ -22,12 +20,11 @@ import { FeedViewType } from "~/lib/enum" import { cn, getOS, isBizId } from "~/lib/utils" import { useAIDailyReportModal } from "~/modules/ai/ai-daily/hooks" import { EntryHeader } from "~/modules/entry-content/header" -import { InboxItem, ListItem } from "~/modules/feed-column/item" import { useRefreshFeedMutation } from "~/queries/feed" import { useFeedById, useFeedHeaderTitle } from "~/store/feed" -import { useSubscriptionStore } from "~/store/subscription" import { MarkAllReadWithOverlay } from "../components/mark-all-button" +import { TimelineTabs } from "./TimelineTabs" export const EntryListHeader: FC<{ totalCount: number @@ -76,7 +73,7 @@ export const EntryListHeader: FC<{ return (
{!titleAtBottom && titleInfo} @@ -276,62 +273,3 @@ const AppendTaildingDivider = ({ children }: { children: React.ReactNode }) => ( )} ) - -const TimelineTabs = () => { - const routerParams = useRouteParams() - const { view, listId, inboxId } = routerParams - - const listsData = useSubscriptionStore((state) => - state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s), - ) - const inboxData = useSubscriptionStore((state) => - state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s), - ) - const hasData = listsData.length > 0 || inboxData.length > 0 - - const timeline = listId || inboxId || "" - - const navigate = useNavigateEntry() - if (!hasData) return null - return ( - { - if (!val) { - navigate({ - feedId: null, - entryId: null, - view, - }) - } - }} - > - - - Yours - - {listsData.map((s) => ( - - - - ))} - {inboxData.map((s) => ( - - - - ))} - - - ) -} diff --git a/apps/renderer/src/modules/entry-column/layouts/TimelineTabs.tsx b/apps/renderer/src/modules/entry-column/layouts/TimelineTabs.tsx new file mode 100644 index 0000000000..33bcc3d771 --- /dev/null +++ b/apps/renderer/src/modules/entry-column/layouts/TimelineTabs.tsx @@ -0,0 +1,64 @@ +import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs" +import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" +import { useRouteParams } from "~/hooks/biz/useRouteParams" +import { InboxItem, ListItem } from "~/modules/feed-column/item" +import { useSubscriptionStore } from "~/store/subscription" + +export const TimelineTabs = () => { + const routerParams = useRouteParams() + const { view, listId, inboxId } = routerParams + + const listsData = useSubscriptionStore((state) => + state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s), + ) + const inboxData = useSubscriptionStore((state) => + state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s), + ) + const hasData = listsData.length > 0 || inboxData.length > 0 + + const timeline = listId || inboxId || "" + + const navigate = useNavigateEntry() + if (!hasData) return null + return ( + { + if (!val) { + navigate({ + feedId: null, + entryId: null, + view, + }) + } + }} + > + + + Yours + + {listsData.map((s) => ( + + + + ))} + {inboxData.map((s) => ( + + + + ))} + + + ) +} From 1a874120ce1ef2ea772fe0a52614c33dfb91e994 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 21 Oct 2024 00:03:32 +0800 Subject: [PATCH 3/9] feat: get server configs --- apps/renderer/src/atoms/server-configs.ts | 8 ++++++ apps/renderer/src/models/types.ts | 2 ++ .../renderer/src/providers/root-providers.tsx | 2 ++ .../src/providers/server-configs-provider.tsx | 15 ++++++++++ apps/renderer/src/queries/server-configs.ts | 12 ++++++++ packages/shared/src/hono.ts | 28 ++++++++++++++++++- 6 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 apps/renderer/src/atoms/server-configs.ts create mode 100644 apps/renderer/src/providers/server-configs-provider.tsx create mode 100644 apps/renderer/src/queries/server-configs.ts diff --git a/apps/renderer/src/atoms/server-configs.ts b/apps/renderer/src/atoms/server-configs.ts new file mode 100644 index 0000000000..d48daba172 --- /dev/null +++ b/apps/renderer/src/atoms/server-configs.ts @@ -0,0 +1,8 @@ +import { atom } from "jotai" + +import { createAtomHooks } from "~/lib/jotai" +import type { ServerConfigs } from "~/models" + +export const [, , useServerConfigs, , getServerConfigs, setServerConfigs] = createAtomHooks( + atom>(null), +) diff --git a/apps/renderer/src/models/types.ts b/apps/renderer/src/models/types.ts index 6fe67938d0..822eb8acf8 100644 --- a/apps/renderer/src/models/types.ts +++ b/apps/renderer/src/models/types.ts @@ -123,3 +123,5 @@ export type ActionsInput = { export const TransactionTypes = ["mint", "purchase", "tip", "withdraw"] as const export type WalletModel = ExtractBizResponse["data"][number] + +export type ServerConfigs = ExtractBizResponse["data"] diff --git a/apps/renderer/src/providers/root-providers.tsx b/apps/renderer/src/providers/root-providers.tsx index 9b357e3a76..c98d2cf16e 100644 --- a/apps/renderer/src/providers/root-providers.tsx +++ b/apps/renderer/src/providers/root-providers.tsx @@ -23,6 +23,7 @@ import { LazyModalStackProvider, // specific import should add `index` postfix } from "./lazy/index" +import { ServerConfigsProvider } from "./server-configs-provider" import { SettingSync } from "./setting-sync" import { StableRouterProvider } from "./stable-router-provider" import { UserProvider } from "./user-provider" @@ -44,6 +45,7 @@ export const RootProviders: FC = ({ children }) => ( + diff --git a/apps/renderer/src/providers/server-configs-provider.tsx b/apps/renderer/src/providers/server-configs-provider.tsx new file mode 100644 index 0000000000..112acc5549 --- /dev/null +++ b/apps/renderer/src/providers/server-configs-provider.tsx @@ -0,0 +1,15 @@ +import { useEffect } from "react" + +import { setServerConfigs } from "~/atoms/server-configs" +import { useServerConfigsQuery } from "~/queries/server-configs" + +export const ServerConfigsProvider = () => { + const serverConfigs = useServerConfigsQuery() + + useEffect(() => { + if (!serverConfigs) return + setServerConfigs(serverConfigs) + }, [serverConfigs]) + + return null +} diff --git a/apps/renderer/src/queries/server-configs.ts b/apps/renderer/src/queries/server-configs.ts new file mode 100644 index 0000000000..108341586c --- /dev/null +++ b/apps/renderer/src/queries/server-configs.ts @@ -0,0 +1,12 @@ +import { useAuthQuery } from "~/hooks/common" +import { apiClient } from "~/lib/api-fetch" +import { defineQuery } from "~/lib/defineQuery" + +export const serverConfigs = { + get: () => defineQuery(["server-configs"], async () => await apiClient.status.configs.$get()), +} + +export const useServerConfigsQuery = () => { + const { data } = useAuthQuery(serverConfigs.get()) + return data?.data +} diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index 793ff12e9c..9379b6a659 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -4431,6 +4431,33 @@ declare const levelsRelations: drizzle_orm.Relations<"levels", { }>; declare const _routes: hono_hono_base.HonoBase Date: Mon, 21 Oct 2024 00:23:58 +0800 Subject: [PATCH 4/9] feat: use server DAILY_CLAIM_AMOUNT and INVITATION_PRICE --- apps/renderer/src/constants/app.tsx | 3 --- .../power/my-wallet-section/claim-daily-reward.tsx | 6 ++++-- .../src/modules/settings/tabs/invitations.tsx | 12 ++++++++---- packages/shared/src/hono.ts | 3 +++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/renderer/src/constants/app.tsx b/apps/renderer/src/constants/app.tsx index 1e1404991d..cea153d90f 100644 --- a/apps/renderer/src/constants/app.tsx +++ b/apps/renderer/src/constants/app.tsx @@ -13,7 +13,4 @@ export const ROUTE_FEED_IN_FOLDER = "folder-" export const ROUTE_FEED_IN_LIST = "list-" export const ROUTE_FEED_IN_INBOX = "inbox-" -export const DAILY_CLAIM_AMOUNT = "20" -export const INVITATION_PRICE = "100" - export const INBOX_PREFIX_ID = "inbox-" diff --git a/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx b/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx index 5572acf416..1dd109ca17 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/claim-daily-reward.tsx @@ -1,9 +1,9 @@ import { TooltipTrigger } from "@radix-ui/react-tooltip" import { Trans, useTranslation } from "react-i18next" +import { useServerConfigs } from "~/atoms/server-configs" import { Button } from "~/components/ui/button" import { Tooltip, TooltipContent } from "~/components/ui/tooltip" -import { DAILY_CLAIM_AMOUNT } from "~/constants" import { useClaimCheck, useClaimWalletDailyRewardMutation } from "~/queries/wallet" export const ClaimDailyReward = () => { @@ -13,6 +13,8 @@ export const ClaimDailyReward = () => { const check = useClaimCheck() const canClaim = check.data?.data + const serverConfigs = useServerConfigs() + return ( @@ -30,7 +32,7 @@ export const ClaimDailyReward = () => { ) : ( t("wallet.claim.tooltip.alreadyClaimed") diff --git a/apps/renderer/src/modules/settings/tabs/invitations.tsx b/apps/renderer/src/modules/settings/tabs/invitations.tsx index ef44dc0976..d255595bf5 100644 --- a/apps/renderer/src/modules/settings/tabs/invitations.tsx +++ b/apps/renderer/src/modules/settings/tabs/invitations.tsx @@ -3,6 +3,7 @@ import dayjs from "dayjs" import { Trans, useTranslation } from "react-i18next" import { toast } from "sonner" +import { useServerConfigs } from "~/atoms/server-configs" import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar" import { Button } from "~/components/ui/button" import { CopyButton } from "~/components/ui/code-highlighter" @@ -19,7 +20,6 @@ import { TableRow, } from "~/components/ui/table" import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "~/components/ui/tooltip" -import { INVITATION_PRICE } from "~/constants" import { useAuthQuery } from "~/hooks/common" import { apiClient } from "~/lib/api-fetch" import { toastFetchError } from "~/lib/error-parser" @@ -35,6 +35,8 @@ export const SettingInvitations = () => { const { present } = useModalStack() const presentUserProfile = usePresentUserProfileModal("drawer") + const serverConfigs = useServerConfigs() + return (
@@ -46,7 +48,7 @@ export const SettingInvitations = () => { void }) => { const newInvitation = useMutation({ mutationKey: ["newInvitation"], mutationFn: () => apiClient.invitations.new.$post(), - async onError(err) { + onError(err) { toastFetchError(err) }, onSuccess(data) { @@ -175,13 +177,15 @@ const ConfirmModalContent = ({ dismiss }: { dismiss: () => void }) => { }, }) + const serverConfigs = useServerConfigs() + return ( <>
, diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index 9379b6a659..c54b2498c3 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -4451,6 +4451,9 @@ declare const _routes: hono_hono_base.HonoBase Date: Mon, 21 Oct 2024 03:28:21 +0800 Subject: [PATCH 5/9] feat: get level multiplier from server configs and reward description --- apps/renderer/src/lib/utils.ts | 27 +++++++ .../modules/power/my-wallet-section/index.tsx | 24 +++--- .../reward-description-modal.tsx | 79 +++++++++++++++++++ .../src/modules/wallet/activity-points.tsx | 2 +- apps/renderer/src/modules/wallet/level.tsx | 8 +- locales/settings/en.json | 8 ++ 6 files changed, 131 insertions(+), 17 deletions(-) create mode 100644 apps/renderer/src/modules/power/my-wallet-section/reward-description-modal.tsx diff --git a/apps/renderer/src/lib/utils.ts b/apps/renderer/src/lib/utils.ts index 25809b5080..64769e3958 100644 --- a/apps/renderer/src/lib/utils.ts +++ b/apps/renderer/src/lib/utils.ts @@ -4,6 +4,7 @@ import { memoize } from "lodash-es" import { twMerge } from "tailwind-merge" import { parse } from "tldts" +import { getServerConfigs } from "~/atoms/server-configs" import type { MediaModel } from "~/models" import type { RSSHubRoute } from "~/modules/discover/types" @@ -286,3 +287,29 @@ export const filterSmallMedia = (media: MediaModel) => { (m) => !(m.type === "photo" && m.width && m.width < 65 && m.height && m.height < 65), ) } + +export const getLevelMultiplier = (level: number) => { + if (level === 0) { + return 0.1 + } + const serverConfigs = getServerConfigs() + if (!serverConfigs) { + return 1 + } + const level1Range = serverConfigs?.LEVEL_PERCENTAGES[3] - serverConfigs?.LEVEL_PERCENTAGES[2] + const percentageIndex = serverConfigs.LEVEL_PERCENTAGES.length - level + let levelCurrentRange + if (percentageIndex - 1 < 0) { + levelCurrentRange = serverConfigs?.LEVEL_PERCENTAGES[percentageIndex] + } else { + levelCurrentRange = + serverConfigs?.LEVEL_PERCENTAGES[percentageIndex] - + serverConfigs?.LEVEL_PERCENTAGES[percentageIndex - 1] + } + const rangeMultiplier = levelCurrentRange / level1Range + + const poolMultiplier = + serverConfigs?.DAILY_POWER_PERCENTAGES[level] / serverConfigs?.DAILY_POWER_PERCENTAGES[1] + + return (poolMultiplier / rangeMultiplier).toFixed(0) +} diff --git a/apps/renderer/src/modules/power/my-wallet-section/index.tsx b/apps/renderer/src/modules/power/my-wallet-section/index.tsx index ebc2b2e2c0..2beda5ea29 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/index.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/index.tsx @@ -1,6 +1,7 @@ import { useMutation } from "@tanstack/react-query" import { Trans, useTranslation } from "react-i18next" +import { useServerConfigs } from "~/atoms/server-configs" import { Button } from "~/components/ui/button" import { CopyButton } from "~/components/ui/code-highlighter" import { Divider } from "~/components/ui/divider" @@ -16,12 +17,16 @@ import { useWallet, wallet as walletActions } from "~/queries/wallet" import { ClaimDailyReward } from "./claim-daily-reward" import { CreateWallet } from "./create-wallet" +import { useRewardDescriptionModal } from "./reward-description-modal" import { WithdrawButton } from "./withdraw" export const MyWalletSection = () => { const { t } = useTranslation("settings") const wallet = useWallet() const myWallet = wallet.data?.[0] + const serverConfigs = useServerConfigs() + + const rewardDescriptionModal = useRewardDescriptionModal() const refreshMutation = useMutation({ mutationFn: async () => { @@ -126,9 +131,11 @@ export const MyWalletSection = () => {
-
- {t("wallet.power.rewardDescription3")} -
+ {serverConfigs?.DISABLE_PERSONAL_DAILY_POWER && ( +
+ {t("wallet.power.rewardDescription3")} +
+ )}
{t("wallet.power.rewardDescription")}
{ components={{ Balance: ( {BigInt(myWallet.todayDailyPower || 0n)} ), - Link: ( - - ), + Link:
diff --git a/apps/renderer/src/modules/power/my-wallet-section/reward-description-modal.tsx b/apps/renderer/src/modules/power/my-wallet-section/reward-description-modal.tsx new file mode 100644 index 0000000000..02006c8742 --- /dev/null +++ b/apps/renderer/src/modules/power/my-wallet-section/reward-description-modal.tsx @@ -0,0 +1,79 @@ +import { from } from "dnum" +import { useCallback } from "react" +import { useTranslation } from "react-i18next" + +import { useServerConfigs } from "~/atoms/server-configs" +import { useModalStack } from "~/components/ui/modal" +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "~/components/ui/table" +import { getLevelMultiplier } from "~/lib/utils" +import { Balance } from "~/modules/wallet/balance" +import { Level } from "~/modules/wallet/level" + +export const useRewardDescriptionModal = () => { + const { present } = useModalStack() + const { t } = useTranslation("settings") + const serverConfigs = useServerConfigs() + + return useCallback(() => { + present({ + content: () => ( +
+
+

{t("wallet.rewardDescription.description1")}

+

1. {t("wallet.rewardDescription.description2")}

+ + + + {t("wallet.rewardDescription.level")} + {t("wallet.rewardDescription.percentage")} + {t("wallet.rewardDescription.reward")} + {t("wallet.rewardDescription.total")} + + + + {serverConfigs?.DAILY_POWER_PERCENTAGES.map((percentage, index) => { + const level = serverConfigs?.DAILY_POWER_PERCENTAGES.length - index - 1 + return ( + + + + + {serverConfigs?.LEVEL_PERCENTAGES[index] * 100}% + {getLevelMultiplier(level)} + + + { + from( + serverConfigs.DAILY_POWER_SUPPLY * + serverConfigs?.DAILY_POWER_PERCENTAGES[level], + 18, + )[0] + } + + + + ) + })} + +
+

2. {t("wallet.rewardDescription.description3")}

+
+
+ ), + title: t("wallet.rewardDescription.title"), + overlay: true, + overlayOptions: { + blur: true, + className: "bg-black/80", + }, + clickOutsideToDismiss: true, + }) + }, [serverConfigs, present, t]) +} diff --git a/apps/renderer/src/modules/wallet/activity-points.tsx b/apps/renderer/src/modules/wallet/activity-points.tsx index 804defb905..945e0babdf 100644 --- a/apps/renderer/src/modules/wallet/activity-points.tsx +++ b/apps/renderer/src/modules/wallet/activity-points.tsx @@ -14,7 +14,7 @@ export const ActivityPoints = ({
{isLoading ? : points} - x{Math.floor(points / 10)} + {Math.floor(points / 10)}x
) } diff --git a/apps/renderer/src/modules/wallet/level.tsx b/apps/renderer/src/modules/wallet/level.tsx index 9b2e8a3879..3b9505560d 100644 --- a/apps/renderer/src/modules/wallet/level.tsx +++ b/apps/renderer/src/modules/wallet/level.tsx @@ -1,6 +1,4 @@ -import { cn } from "~/lib/utils" - -export const multiples = [0.1, 1, 2, 5, 18] +import { cn, getLevelMultiplier } from "~/lib/utils" export const Level = ({ level, @@ -21,7 +19,9 @@ export const Level = ({ ) : ( <> Lv.{level} - x{multiples[level]} + + {getLevelMultiplier(level)}x + )}
diff --git a/locales/settings/en.json b/locales/settings/en.json index 43e2a952e9..c7e53cb205 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -240,6 +240,14 @@ "wallet.ranking.power": "Power", "wallet.ranking.rank": "Rank", "wallet.ranking.title": "Power Ranking", + "wallet.rewardDescription.description1": "The daily rewards for each user are based on two factors: user level and user activity points.", + "wallet.rewardDescription.description2": "User level: Determined by the user's Power ranking compared to all other users.", + "wallet.rewardDescription.description3": "User Activity: Engaging with various Follow features can boost activity. Rewards range from a minimum of 1x to a maximum of 10x.", + "wallet.rewardDescription.level": "User Level", + "wallet.rewardDescription.percentage": "Ranking Percentage", + "wallet.rewardDescription.reward": "Reward Multiplier", + "wallet.rewardDescription.title": "Reward Description", + "wallet.rewardDescription.total": "Total Reward Per Day", "wallet.sidebar_title": "Power", "wallet.transactions.amount": "Amount", "wallet.transactions.date": "Date", From c1582f9e95a02984298ee38a3095d50775ff0e11 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 21 Oct 2024 03:46:40 +0800 Subject: [PATCH 6/9] feat: tax tips --- .../power/transaction-section/index.tsx | 25 +++++++++++++++++-- locales/settings/en.json | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/renderer/src/modules/power/transaction-section/index.tsx b/apps/renderer/src/modules/power/transaction-section/index.tsx index ea3cd63d27..d25ad9f0f3 100644 --- a/apps/renderer/src/modules/power/transaction-section/index.tsx +++ b/apps/renderer/src/modules/power/transaction-section/index.tsx @@ -1,6 +1,7 @@ import { useState } from "react" import { useTranslation } from "react-i18next" +import { useServerConfigs } from "~/atoms/server-configs" import { useWhoami } from "~/atoms/user" import { Logo } from "~/components/icons/logo" import { Avatar, AvatarFallback, AvatarImage } from "~/components/ui/avatar" @@ -40,11 +41,18 @@ export const TransactionsSection: Component = ({ className }) => { type: type === "all" ? undefined : type, }) + const serverConfigs = useServerConfigs() + if (!myWallet) return null return ( + {!!transactions.data?.length && ( + + {t("wallet.transactions.more")} + + )} {!transactions.data?.length && ( -
+
{t("wallet.transactions.noTransactions")}
)} diff --git a/locales/settings/en.json b/locales/settings/en.json index c7e53cb205..f916c08311 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -251,7 +251,9 @@ "wallet.sidebar_title": "Power", "wallet.transactions.amount": "Amount", "wallet.transactions.date": "Date", + "wallet.transactions.description": "Certain transactions incur a {{percentage}}% platform fee to support Follow go further. For details, please refer to the blockchain transaction.", "wallet.transactions.from": "From", + "wallet.transactions.more": "View more through the blockchain explorer.", "wallet.transactions.noTransactions": "No transactions", "wallet.transactions.title": "Transactions", "wallet.transactions.to": "To", From 133a0678406ec537c009be641d2a9b3b3bf57d6f Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 21 Oct 2024 03:54:36 +0800 Subject: [PATCH 7/9] fix: testnet explorer url --- apps/renderer/src/lib/utils.ts | 10 ++++++++++ .../src/modules/power/my-wallet-section/index.tsx | 6 +++--- .../src/modules/power/transaction-section/index.tsx | 6 +++--- packages/shared/src/hono.ts | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/renderer/src/lib/utils.ts b/apps/renderer/src/lib/utils.ts index 64769e3958..d24ad59fbf 100644 --- a/apps/renderer/src/lib/utils.ts +++ b/apps/renderer/src/lib/utils.ts @@ -313,3 +313,13 @@ export const getLevelMultiplier = (level: number) => { return (poolMultiplier / rangeMultiplier).toFixed(0) } + +export const getBlockchainExplorerUrl = () => { + const serverConfigs = getServerConfigs() + + if (serverConfigs?.IS_RSS3_TESTNET) { + return `https://scan.testnet.rss3.io` + } else { + return `https://scan.rss3.io` + } +} diff --git a/apps/renderer/src/modules/power/my-wallet-section/index.tsx b/apps/renderer/src/modules/power/my-wallet-section/index.tsx index 2beda5ea29..c7f8db012d 100644 --- a/apps/renderer/src/modules/power/my-wallet-section/index.tsx +++ b/apps/renderer/src/modules/power/my-wallet-section/index.tsx @@ -8,7 +8,7 @@ import { Divider } from "~/components/ui/divider" import { LoadingWithIcon } from "~/components/ui/loading" import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "~/components/ui/tooltip" import { apiClient } from "~/lib/api-fetch" -import { cn } from "~/lib/utils" +import { cn, getBlockchainExplorerUrl } from "~/lib/utils" import { SettingSectionTitle } from "~/modules/settings/section" import { ActivityPoints } from "~/modules/wallet/activity-points" import { Balance } from "~/modules/wallet/balance" @@ -66,7 +66,7 @@ export const MyWalletSection = () => { ), @@ -76,7 +76,7 @@ export const MyWalletSection = () => {
diff --git a/apps/renderer/src/modules/power/transaction-section/index.tsx b/apps/renderer/src/modules/power/transaction-section/index.tsx index d25ad9f0f3..dda1695d2d 100644 --- a/apps/renderer/src/modules/power/transaction-section/index.tsx +++ b/apps/renderer/src/modules/power/transaction-section/index.tsx @@ -19,7 +19,7 @@ import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs" import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger } from "~/components/ui/tooltip" import { EllipsisHorizontalTextWithTooltip } from "~/components/ui/typography" import { replaceImgUrlIfNeed } from "~/lib/img-proxy" -import { cn } from "~/lib/utils" +import { cn, getBlockchainExplorerUrl } from "~/lib/utils" import { TransactionTypes } from "~/models/types" import { usePresentUserProfileModal } from "~/modules/profile/hooks" import { SettingSectionTitle } from "~/modules/settings/section" @@ -103,7 +103,7 @@ export const TransactionsSection: Component = ({ className }) => { {row.hash.slice(0, 10)}... @@ -122,7 +122,7 @@ export const TransactionsSection: Component = ({ className }) => { {!!transactions.data?.length && ( {t("wallet.transactions.more")} diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index c54b2498c3..8448dca6f1 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -4454,6 +4454,7 @@ declare const _routes: hono_hono_base.HonoBase Date: Mon, 21 Oct 2024 08:32:15 +0800 Subject: [PATCH 8/9] fix: not showing '0' when no followers on the search results card (#1032) --- apps/renderer/src/modules/discover/form.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/renderer/src/modules/discover/form.tsx b/apps/renderer/src/modules/discover/form.tsx index 053cb53084..cc58b5a0f2 100644 --- a/apps/renderer/src/modules/discover/form.tsx +++ b/apps/renderer/src/modules/discover/form.tsx @@ -342,7 +342,7 @@ const SearchCard: FC<{
- {item.subscriptionCount} + {item.subscriptionCount ?? 0} {" "} Followers
From 93461e8ad7ed47adba6afa351c816d1392ecc2f7 Mon Sep 17 00:00:00 2001 From: Kieran Cui <78460423+cuikaipeng@users.noreply.github.com> Date: Mon, 21 Oct 2024 08:32:47 +0800 Subject: [PATCH 9/9] fix: the search results on the Discover Page are not centered (#1029) --- .../src/pages/(main)/(layer)/(subview)/discover/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx b/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx index cf4b570167..b841ead2b9 100644 --- a/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx +++ b/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx @@ -106,7 +106,7 @@ export function Component() { {currentTabs.map((tab) => ( -
+
{createElement(TabComponent[tab.value] || TabComponent.default, { type: tab.value, })}