fix(desktop): auto enable readability

This commit is contained in:
Stephen Zhou 2025-06-04 16:41:51 +08:00
parent 0a167ac557
commit 80b36b5408
No known key found for this signature in database
2 changed files with 9 additions and 10 deletions

View File

@ -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

View File

@ -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