From b046be71fe9fc91d5706759373e8a17b6074c203 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 21 Apr 2025 16:34:44 +0800 Subject: [PATCH] feat(desktop): hide tip and boost for mas --- .../renderer/src/hooks/biz/useFeedActions.tsx | 19 +++++--- apps/desktop/src/renderer/src/lib/utils.ts | 5 +++ .../src/modules/command/commands/entry.tsx | 33 ++++++++------ .../components/SupportCreator.tsx | 43 ++++++++++--------- packages/shared/src/hono.ts | 1 + 5 files changed, 60 insertions(+), 41 deletions(-) diff --git a/apps/desktop/src/renderer/src/hooks/biz/useFeedActions.tsx b/apps/desktop/src/renderer/src/hooks/biz/useFeedActions.tsx index 1df39c7e7..e49c84d94 100644 --- a/apps/desktop/src/renderer/src/hooks/biz/useFeedActions.tsx +++ b/apps/desktop/src/renderer/src/hooks/biz/useFeedActions.tsx @@ -13,6 +13,7 @@ import { whoami } from "~/atoms/user" import { useModalStack } from "~/components/ui/modal/stacked/hooks" import { apiClient } from "~/lib/api-fetch" import { UrlBuilder } from "~/lib/url-builder" +import { isInMASReview } from "~/lib/utils" import { useBoostModal } from "~/modules/boost/hooks" import { useFeedClaimModal } from "~/modules/claim" import { FeedForm } from "~/modules/discover/feed-form" @@ -147,13 +148,17 @@ export const useFeedActions = ({ }, ] : []), - { - type: "text" as const, - label: t("words.boost"), - click: () => { - openBoostModal(feedId) - }, - }, + ...(isInMASReview() + ? [] + : [ + { + type: "text" as const, + label: t("words.boost"), + click: () => { + openBoostModal(feedId) + }, + }, + ]), { type: "separator" as const, disabled: isEntryList, diff --git a/apps/desktop/src/renderer/src/lib/utils.ts b/apps/desktop/src/renderer/src/lib/utils.ts index 9e84f0a6e..531c8b9fb 100644 --- a/apps/desktop/src/renderer/src/lib/utils.ts +++ b/apps/desktop/src/renderer/src/lib/utils.ts @@ -108,3 +108,8 @@ export const getBlockchainExplorerUrl = () => { export const isInMAS = () => { return typeof process !== "undefined" && process.mas } + +export const isInMASReview = () => { + const serverConfigs = getServerConfigs() + return isInMAS() && serverConfigs?.MAS_IN_REVIEW +} diff --git a/apps/desktop/src/renderer/src/modules/command/commands/entry.tsx b/apps/desktop/src/renderer/src/modules/command/commands/entry.tsx index f9e526dac..4e8dcca0c 100644 --- a/apps/desktop/src/renderer/src/modules/command/commands/entry.tsx +++ b/apps/desktop/src/renderer/src/modules/command/commands/entry.tsx @@ -20,6 +20,7 @@ import { navigateEntry } from "~/hooks/biz/useNavigateEntry" import { getRouteParams } from "~/hooks/biz/useRouteParams" import { tipcClient } from "~/lib/client" import { parseHtml } from "~/lib/parse-html" +import { isInMASReview } from "~/lib/utils" import { useActivationModal } from "~/modules/activation" import { useGalleryModal } from "~/modules/entry-content/hooks" import { useTipModal } from "~/modules/wallet/hooks" @@ -107,20 +108,24 @@ export const useRegisterEntryCommands = () => { const voice = useGeneralSettingKey("voice") useRegisterFollowCommand([ - { - id: COMMAND_ID.entry.tip, - label: t("entry_actions.tip"), - icon: , - // keyBinding: shortcuts.entry.tip.key, - // when: !isInbox && feed?.ownerUserId !== whoami()?.id && !!populatedEntry, - run: ({ userId, feedId, entryId }) => { - openTipModal({ - userId, - feedId, - entryId, - }) - }, - }, + ...(isInMASReview() + ? ([] as any[]) + : [ + { + id: COMMAND_ID.entry.tip, + label: t("entry_actions.tip"), + icon: , + // keyBinding: shortcuts.entry.tip.key, + // when: !isInbox && feed?.ownerUserId !== whoami()?.id && !!populatedEntry, + run: ({ userId, feedId, entryId }) => { + openTipModal({ + userId, + feedId, + entryId, + }) + }, + }, + ]), { id: COMMAND_ID.entry.star, label: t("entry_actions.star"), diff --git a/apps/desktop/src/renderer/src/modules/entry-content/components/SupportCreator.tsx b/apps/desktop/src/renderer/src/modules/entry-content/components/SupportCreator.tsx index 4a2f21571..722791229 100644 --- a/apps/desktop/src/renderer/src/modules/entry-content/components/SupportCreator.tsx +++ b/apps/desktop/src/renderer/src/modules/entry-content/components/SupportCreator.tsx @@ -4,6 +4,7 @@ import { useMemo } from "react" import { useTranslation } from "react-i18next" import { useWhoami } from "~/atoms/user" +import { isInMASReview } from "~/lib/utils" import { useBoostModal } from "~/modules/boost/hooks" import { useFeedBoostersQuery } from "~/modules/boost/query" import { FeedIcon } from "~/modules/feed/feed-icon" @@ -54,29 +55,31 @@ export const SupportCreator = ({ entryId }: { entryId: string }) => { )} {feed.title} -
- {!isMyOwnedFeed && ( + {!isInMASReview() && ( +
+ {!isMyOwnedFeed && ( + + )} - )} - -
+
+ )} {supportAmount > 0 && ( <> diff --git a/packages/shared/src/hono.ts b/packages/shared/src/hono.ts index c6365760f..b49b04047 100644 --- a/packages/shared/src/hono.ts +++ b/packages/shared/src/hono.ts @@ -15937,6 +15937,7 @@ declare const _routes: hono_hono_base.HonoBase