From 9b99bf4428cf6f1ca3218a3074a944af4d014f57 Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 31 Oct 2024 00:05:50 +0800 Subject: [PATCH] fix: optimize some styles Signed-off-by: Innei --- .../src/hooks/biz/useEntryActions.tsx | 7 +++++-- .../src/modules/boost/boost-progress.tsx | 2 +- apps/renderer/src/modules/boost/modal.tsx | 21 ++++++++++++++----- .../entry-column/layouts/EntryItemWrapper.tsx | 2 ++ .../entry-column/layouts/EntryListHeader.tsx | 5 +++-- .../src/modules/entry-content/header.tsx | 3 +++ apps/renderer/src/store/feed/selector.ts | 13 ++++++++++++ 7 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 apps/renderer/src/store/feed/selector.ts diff --git a/apps/renderer/src/hooks/biz/useEntryActions.tsx b/apps/renderer/src/hooks/biz/useEntryActions.tsx index 48d8d4f90..612a0e6cb 100644 --- a/apps/renderer/src/hooks/biz/useEntryActions.tsx +++ b/apps/renderer/src/hooks/biz/useEntryActions.tsx @@ -153,10 +153,12 @@ export const useEntryActions = ({ view, entry, type, + inList, }: { view?: number entry?: FlatEntryModel | null type?: "toolbar" | "entryList" + inList?: boolean }) => { const { t } = useTranslation() @@ -624,7 +626,7 @@ export const useEntryActions = ({ name: t("entry_actions.mark_as_read"), shortcut: shortcuts.entry.toggleRead.key, className: "i-mgc-round-cute-fi", - hide: !!(!!populatedEntry.read || populatedEntry.collections), + hide: !!(!!populatedEntry.read || populatedEntry.collections) || inList, onClick: () => { read.mutate(populatedEntry) }, @@ -634,7 +636,7 @@ export const useEntryActions = ({ name: t("entry_actions.mark_as_unread"), shortcut: shortcuts.entry.toggleRead.key, className: "i-mgc-round-cute-re", - hide: !!(!populatedEntry.read || populatedEntry.collections), + hide: !!(!populatedEntry.read || populatedEntry.collections) || inList, onClick: () => { unread.mutate(populatedEntry) }, @@ -662,6 +664,7 @@ export const useEntryActions = ({ feed?.ownerUserId, type, showSourceContent, + inList, saveToObsidian, obsidianVaultPath, openTipModal, diff --git a/apps/renderer/src/modules/boost/boost-progress.tsx b/apps/renderer/src/modules/boost/boost-progress.tsx index 380f2a52a..4690e8a81 100644 --- a/apps/renderer/src/modules/boost/boost-progress.tsx +++ b/apps/renderer/src/modules/boost/boost-progress.tsx @@ -36,7 +36,7 @@ export const BoostProgress = ({ {numberFormater.format(boostCount)} -
+
{ boostFeedMutation.mutate({ feedId, amount: amountBigInt.toString() }) }, [amountBigInt, boostFeedMutation, feedId]) + const feed = useFeedById(feedId, feedIconSelector) + if (isLoading || !boostStatus) { return (
@@ -46,12 +51,18 @@ export const BoostModalContent = ({ feedId }: { feedId: string }) => { return (
-
-
- - {t("boost.boost_feed")} -
+
+ +

+
+ + {t("boost.boost_feed")} +
+ 「{feed?.title}」 +

+
+
{t("boost.boost_feed_description")} diff --git a/apps/renderer/src/modules/entry-column/layouts/EntryItemWrapper.tsx b/apps/renderer/src/modules/entry-column/layouts/EntryItemWrapper.tsx index 8ce054b21..5d200f008 100644 --- a/apps/renderer/src/modules/entry-column/layouts/EntryItemWrapper.tsx +++ b/apps/renderer/src/modules/entry-column/layouts/EntryItemWrapper.tsx @@ -25,10 +25,12 @@ export const EntryItemWrapper: FC< style?: React.CSSProperties } & PropsWithChildren > = ({ entry, view, children, itemClassName, style }) => { + const listId = useRouteParamsSelector((s) => s.listId) const { items } = useEntryActions({ view, entry, type: "entryList", + inList: !!listId, }) const { items: feedItems } = useFeedActions({ diff --git a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx index 80f566ca5..bb219b42b 100644 --- a/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx +++ b/apps/renderer/src/modules/entry-column/layouts/EntryListHeader.tsx @@ -15,7 +15,7 @@ import { setGeneralSetting, useGeneralSettingKey } from "~/atoms/settings/genera import { setUISetting, useUISettingKey } from "~/atoms/settings/ui" import { useWhoami } from "~/atoms/user" import { ImpressionView } from "~/components/common/ImpressionTracker" -import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING } from "~/constants" +import { FEED_COLLECTION_LIST, ROUTE_ENTRY_PENDING, ROUTE_FEED_IN_LIST } from "~/constants" import { shortcuts } from "~/constants/shortcuts" import { useRouteParams } from "~/hooks/biz/useRouteParams" import { useAIDailyReportModal } from "~/modules/ai/ai-daily/useAIDailyReportModal" @@ -42,7 +42,8 @@ export const EntryListHeader: FC<{ const os = getOS() const titleAtBottom = IN_ELECTRON && os === "macOS" - const isInCollectionList = feedId === FEED_COLLECTION_LIST + const isInCollectionList = + feedId === FEED_COLLECTION_LIST || feedId?.startsWith(ROUTE_FEED_IN_LIST) const titleInfo = !!headerTitle && (
diff --git a/apps/renderer/src/modules/entry-content/header.tsx b/apps/renderer/src/modules/entry-content/header.tsx index 88a317935..57555e7ab 100644 --- a/apps/renderer/src/modules/entry-content/header.tsx +++ b/apps/renderer/src/modules/entry-content/header.tsx @@ -19,6 +19,7 @@ import { import { useUISettingKey } from "~/atoms/settings/ui" import { shortcuts } from "~/constants/shortcuts" import { useEntryActions, useEntryReadabilityToggle } from "~/hooks/biz/useEntryActions" +import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams" import { tipcClient } from "~/lib/client" import { parseHtml } from "~/lib/parse-html" import type { FlatEntryModel } from "~/store/entry" @@ -41,10 +42,12 @@ function EntryHeaderImpl({ }) { const entry = useEntry(entryId) + const listId = useRouteParamsSelector((s) => s.listId) const { items } = useEntryActions({ view, entry, type: "toolbar", + inList: !!listId, }) const entryTitleMeta = useEntryTitleMeta() diff --git a/apps/renderer/src/store/feed/selector.ts b/apps/renderer/src/store/feed/selector.ts new file mode 100644 index 000000000..bcfa098c8 --- /dev/null +++ b/apps/renderer/src/store/feed/selector.ts @@ -0,0 +1,13 @@ +import type { FeedModel } from "@follow/models" + +export const feedIconSelector = (feed: FeedModel) => { + return { + type: feed.type, + ownerUserId: feed.ownerUserId, + id: feed.id, + title: feed.title, + url: (feed as any).url || "", + image: feed.image, + siteUrl: feed.siteUrl, + } +}