From c3ed8eeb2df4ef9840ce9bc374b7a9b75ff3e9b6 Mon Sep 17 00:00:00 2001 From: Cason Kervis Date: Mon, 14 Jul 2025 17:08:38 +0800 Subject: [PATCH] feat: hide view count when hideRecentReader is on (#4167) --- .../modules/entry-content/components/EntryTitle.tsx | 4 +++- .../(stack)/entries/[entryId]/EntryDetailScreen.tsx | 11 ++++++++++- locales/settings/en.json | 4 ++-- locales/settings/zh-CN.json | 4 ++-- plugins/eslint/eslint-check-i18n-json.js | 6 ++++-- 5 files changed, 21 insertions(+), 8 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx index 872f43dde..e5ddcac10 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/EntryTitle.tsx @@ -65,6 +65,8 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { const navigateEntry = useNavigateEntry() + const hideRecentReader = useUISettingKey("hideRecentReader") + if (!entry) return null return compact ? ( @@ -132,7 +134,7 @@ export const EntryTitle = ({ entryId, compact }: EntryLinkProps) => { (entryHistory?.readCount ?? 0) + (entryHistory?.userIds?.every((id) => id !== user?.id) ? 1 : 0) - return readCount > 0 ? ( + return readCount > 0 && !hideRecentReader ? (
{readCount.toLocaleString()} diff --git a/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx b/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx index 128923df4..2a753ab81 100644 --- a/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx +++ b/apps/mobile/src/screens/(stack)/entries/[entryId]/EntryDetailScreen.tsx @@ -1,5 +1,5 @@ import { FeedViewType } from "@follow/constants" -import { useEntry, usePrefetchEntryDetail } from "@follow/store/entry/hooks" +import { useEntry, useEntryReadHistory, usePrefetchEntryDetail } from "@follow/store/entry/hooks" import { entrySyncServices } from "@follow/store/entry/store" import { useFeedById } from "@follow/store/feed/hooks" import { usePrefetchEntryTranslation } from "@follow/store/translation/hooks" @@ -12,6 +12,7 @@ import { useSafeAreaInsets } from "react-native-safe-area-context" import { useColor } from "react-native-uikit-colors" import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general" +import { useUISettingKey } from "@/src/atoms/settings/ui" import { BottomTabBarHeightContext } from "@/src/components/layouts/tabbar/contexts/BottomTabBarHeightContext" import { SafeNavigationScrollView } from "@/src/components/layouts/views/SafeNavigationScrollView" import { EntryContentWebView } from "@/src/components/native/webview/EntryContentWebView" @@ -181,6 +182,9 @@ const EntryInfo = ({ entryId }: { entryId: string }) => { const feed = useFeedById(entry?.feedId) const secondaryLabelColor = useColor("secondaryLabel") + const readCount = useEntryReadHistory(entryId)?.entryReadHistories?.readCount + const hideRecentReader = useUISettingKey("hideRecentReader") + if (!entry) return null const { publishedAt } = entry @@ -202,6 +206,11 @@ const EntryInfo = ({ entryId }: { entryId: string }) => { className="text-secondary-label text-sm leading-tight" /> + {!hideRecentReader && ( + + {readCount} + + )} ) } diff --git a/locales/settings/en.json b/locales/settings/en.json index 47d4602f0..d1083e9c0 100644 --- a/locales/settings/en.json +++ b/locales/settings/en.json @@ -120,8 +120,8 @@ "appearance.guess_code_language.label": "Guess Code Language", "appearance.hide_extra_badge.description": "Hide the Special Badge of the Feed in the Sidebar, e.g. Boost, Claimed", "appearance.hide_extra_badge.label": "Hide Special Badge", - "appearance.hide_recent_reader.description": "Hide the Recent Reader in the Entry Header.", - "appearance.hide_recent_reader.label": "Hide Recent Reader", + "appearance.hide_recent_reader.description": "Hide the Recent Reader and View Count in the Entry.", + "appearance.hide_recent_reader.label": "Hide Recent Readers & View Count", "appearance.interface_window.title": "Interface & Window", "appearance.misc": "Misc", "appearance.modal_overlay.description": "Show Modal Overlay", diff --git a/locales/settings/zh-CN.json b/locales/settings/zh-CN.json index 06c7c71ce..64a82612c 100644 --- a/locales/settings/zh-CN.json +++ b/locales/settings/zh-CN.json @@ -120,8 +120,8 @@ "appearance.guess_code_language.label": "代码语言检测", "appearance.hide_extra_badge.description": "将侧边栏中订阅源的特殊徽章隐藏,例如:已助力,已认证", "appearance.hide_extra_badge.label": "隐藏徽章", - "appearance.hide_recent_reader.description": "隐藏条目标题显示的最近阅读者。", - "appearance.hide_recent_reader.label": "隐藏最近阅读者", + "appearance.hide_recent_reader.description": "隐藏条目标题显示的最近阅读者与阅读数。", + "appearance.hide_recent_reader.label": "隐藏最近阅读者与阅读数", "appearance.interface_window.title": "界面与窗口", "appearance.misc": "杂项", "appearance.modal_overlay.description": "显示遮罩以获得更好的使用体验,推荐开启。", diff --git a/plugins/eslint/eslint-check-i18n-json.js b/plugins/eslint/eslint-check-i18n-json.js index 7b3496c19..71ec3e644 100644 --- a/plugins/eslint/eslint-check-i18n-json.js +++ b/plugins/eslint/eslint-check-i18n-json.js @@ -2,7 +2,7 @@ /** @type {import("eslint").ESLint.Plugin} */ import fs from "node:fs" -import path from "pathe" +import path, { normalize, sep } from "pathe" import { cleanJsonText } from "../utils.js" @@ -84,7 +84,8 @@ export default { if (!filename.endsWith(".json")) return - const parts = filename.split(path.sep) + const parts = normalize(filename).split(sep) + // @ts-ignore const lang = parts.at(-1).split(".")[0] const namespace = parts.at(-2) @@ -95,6 +96,7 @@ export default { try { currentJson = JSON.parse(sourceCode.text) + // @ts-ignore const englishFilePath = path.join(path.dirname(filename), "../", namespace, "en.json") englishJson = JSON.parse(fs.readFileSync(englishFilePath, "utf8")) } catch (error) {