1+ import { parseHtml } from "@follow/components/ui/markdown/parse-html.ts"
12import { useEntry } from "@follow/store/entry/hooks"
23import { SummaryGeneratingStatus } from "@follow/store/summary/enum"
34import { usePrefetchSummary , useSummary } from "@follow/store/summary/hooks"
45import { useSummaryStore } from "@follow/store/summary/store"
56import { useAtomValue } from "jotai"
67import type { FC } from "react"
7- import { useMemo } from "react"
8+ import { useCallback , useMemo } from "react"
89import { Text } from "react-native"
910
1011import { useActionLanguage , useGeneralSettingKey } from "@/src/atoms/settings/general"
@@ -21,14 +22,30 @@ export const EntryAISummary: FC<{
2122 const showReadability = useAtomValue ( ctx . showReadabilityAtom )
2223 const showAISummaryOnce = useAtomValue ( ctx . showAISummaryAtom )
2324 const showAISummary = useGeneralSettingKey ( "summary" ) || showAISummaryOnce
24- const entryReadabilityContent = useEntry ( entryId , ( state ) => state . readabilityContent )
25+ const entry = useEntry (
26+ entryId ,
27+ useCallback (
28+ ( state ) => {
29+ const content = showReadability ? state . readabilityContent : state . content
30+ const target =
31+ showReadability && state . readabilityContent ? "readabilityContent" : "content"
32+ const textLength = content ? parseHtml ( content ) . toText ( ) . length : 0
33+
34+ return {
35+ target,
36+ isShortContent : textLength < 100 ,
37+ } as const
38+ } ,
39+ [ showReadability ] ,
40+ ) ,
41+ )
2542 const summary = useSummary ( entryId )
2643 const actionLanguage = useActionLanguage ( )
2744 usePrefetchSummary ( {
2845 entryId,
29- target : showReadability && entryReadabilityContent ? "readabilityContent" : "content" ,
46+ target : entry ?. target || "content" ,
3047 actionLanguage,
31- enabled : showAISummary ,
48+ enabled : showAISummary && ! entry ?. isShortContent ,
3249 } )
3350 const summaryToShow = useMemo ( ( ) => {
3451 const maybeMarkdown = showReadability
0 commit comments