Skip to content

Commit c5edc76

Browse files
committed
fix: auto view source content fail, close #4119
1 parent d4b3406 commit c5edc76

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

apps/desktop/layer/renderer/src/hooks/biz/useNavigateEntry.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { getReadonlyRoute, getStableRouterNavigate } from "@follow/components/at
22
import { useMobile } from "@follow/components/hooks/useMobile.js"
33
import { useSheetContext } from "@follow/components/ui/sheet/context.js"
44
import type { FeedViewType } from "@follow/constants"
5+
import { getEntry } from "@follow/store/entry/getter"
56
import { getSubscriptionByFeedId } from "@follow/store/subscription/getter"
67
import { tracker } from "@follow/tracker"
7-
import { nextFrame } from "@follow/utils"
88
import { useCallback } from "react"
99
import { toast } from "sonner"
1010

@@ -129,10 +129,10 @@ export const navigateEntry = (options: NavigateEntryOptions) => {
129129

130130
disableShowAISummaryOnce()
131131
disableShowAITranslationOnce()
132-
133-
nextFrame(() => {
132+
const sourceContent = getEntry(parsedOptions.entryId)?.settings?.sourceContent
133+
if (!sourceContent) {
134134
resetShowSourceContent()
135-
})
135+
}
136136

137137
const navigate = getStableRouterNavigate()
138138

apps/desktop/layer/renderer/src/modules/entry-content/ApplyEntryActions.tsx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEntry } from "@follow/store/entry/hooks"
2-
import { useEffect, useRef } from "react"
2+
import { useEffect } from "react"
33

44
import { enableShowSourceContent } from "~/atoms/source-content"
55
import { enableEntryReadability } from "~/hooks/biz/useEntryActions"
@@ -18,22 +18,19 @@ export const ApplyEntryActions = ({ entryId }: { entryId: string }) => {
1818
}
1919
})
2020

21-
useViewSourceContentAutoToggleEffect(entry?.sourceContent)
22-
2321
return (
24-
<>{entry?.readability && <ReadabilityAutoToggleEffect id={entryId} url={entry?.url ?? ""} />}</>
22+
<>
23+
{entry?.sourceContent && <ViewSourceContentAutoToggleEffect id={entryId} />}
24+
{entry?.readability && <ReadabilityAutoToggleEffect id={entryId} url={entry?.url ?? ""} />}
25+
</>
2526
)
2627
}
2728

28-
const useViewSourceContentAutoToggleEffect = (when: boolean | undefined) => {
29-
const onceRef = useRef(false)
29+
const ViewSourceContentAutoToggleEffect = ({ id }: { id: string }) => {
3030
useEffect(() => {
31-
if (!when) return
32-
if (!onceRef.current) {
33-
onceRef.current = true
34-
enableShowSourceContent()
35-
}
36-
}, [when])
31+
enableShowSourceContent()
32+
}, [id])
33+
return null
3734
}
3835

3936
export const ReadabilityAutoToggleEffect = ({ url, id }: { url: string; id: string }) => {

0 commit comments

Comments
 (0)