diff --git a/apps/desktop/layer/renderer/src/hooks/biz/useEntryActions.tsx b/apps/desktop/layer/renderer/src/hooks/biz/useEntryActions.tsx index 42433e3ef..edc73f66d 100644 --- a/apps/desktop/layer/renderer/src/hooks/biz/useEntryActions.tsx +++ b/apps/desktop/layer/renderer/src/hooks/biz/useEntryActions.tsx @@ -29,6 +29,13 @@ import { useEntry } from "~/store/entry" import { useFeedById } from "~/store/feed" import { useInboxById } from "~/store/inbox" +export const enableEntryReadability = async ({ id, url }: { id: string; url: string }) => { + const status = getReadabilityStatus()[id] + const isTurnOn = status !== ReadabilityStatus.INITIAL && !!status + if (isTurnOn) return + toggleEntryReadability({ id, url }) +} + export const toggleEntryReadability = async ({ id, url }: { id: string; url: string }) => { const status = getReadabilityStatus()[id] const isTurnOn = status !== ReadabilityStatus.INITIAL && !!status diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/index.shared.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/index.shared.tsx index d95fee4c4..4591eaab9 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/index.shared.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/index.shared.tsx @@ -23,7 +23,7 @@ import { import { enableShowSourceContent } from "~/atoms/source-content" import type { TocRef } from "~/components/ui/markdown/components/Toc" import { Toc } from "~/components/ui/markdown/components/Toc" -import { toggleEntryReadability } from "~/hooks/biz/useEntryActions" +import { enableEntryReadability } from "~/hooks/biz/useEntryActions" import { getNewIssueUrl } from "~/lib/issues" import { useIsSoFWrappedElement, @@ -164,16 +164,8 @@ export const ViewSourceContentAutoToggleEffect = () => { } export const ReadabilityAutoToggleEffect = ({ url, id }: { url: string; id: string }) => { - const onceRef = useRef(false) - useEffect(() => { - if (!onceRef.current) { - onceRef.current = true - setReadabilityStatus({ - [id]: ReadabilityStatus.INITIAL, - }) - toggleEntryReadability({ id, url }) - } + enableEntryReadability({ id, url }) }, [id, url]) return null