fix(desktop): prefetch entry detail for entry not exist

This commit is contained in:
Stephen Zhou 2025-08-13 15:15:55 +08:00
parent 84c84d8d60
commit 649f623e7d
No known key found for this signature in database
4 changed files with 8 additions and 3 deletions

View File

@ -1,5 +1,6 @@
import { PanelSplitter } from "@follow/components/ui/divider/PanelSplitter.js"
import { views } from "@follow/constants"
import { usePrefetchEntryDetail } from "@follow/store/entry/hooks"
import { clsx, cn } from "@follow/utils/utils"
import { easeOut } from "motion/react"
import type { FC, PropsWithChildren } from "react"
@ -28,6 +29,7 @@ const EntryLayoutContentLegacy = () => {
const settingWideMode = useRealInWideMode()
const realEntryId = entryId === ROUTE_ENTRY_PENDING ? "" : entryId
usePrefetchEntryDetail(realEntryId)
const showEntryContent = !(views[view]!.wideMode || (settingWideMode && !realEntryId))
const wideMode = !!(settingWideMode && realEntryId)
const feedColumnTempShow = useTimelineColumnTempShow()

View File

@ -120,7 +120,7 @@ export const useEntriesQuery = (
}, [entriesIds, query])
}
export const usePrefetchEntryDetail = (entryId: string, isInbox?: boolean) => {
export const usePrefetchEntryDetail = (entryId: string | undefined, isInbox?: boolean) => {
return useQuery({
queryKey: ["entry", entryId],
queryFn: () => entrySyncServices.fetchEntryDetail(entryId, isInbox),

View File

@ -1,5 +1,6 @@
import { FeedViewType } from "@follow/constants"
import { EntryService } from "@follow/database/services/entry"
import { isBizId } from "@follow/utils"
import { cloneDeep } from "es-toolkit"
import { debounce } from "es-toolkit/compat"
@ -543,7 +544,9 @@ class EntrySyncServices {
return res
}
async fetchEntryDetail(entryId: EntryId, isInbox?: boolean) {
async fetchEntryDetail(entryId: EntryId | undefined, isInbox?: boolean) {
if (!isBizId(entryId)) return null
const currentEntry = getEntry(entryId)
const res =
currentEntry?.inboxHandle || isInbox

View File

@ -118,7 +118,7 @@ export const isASCII = (str: string) => /^[\u0000-\u007F]*$/.test(str)
const EPOCH = 1712546615000n // follow repo created
const MAX_TIMESTAMP_BITS = 41n // Maximum number of bits typically used for timestamp
export const isBizId = (id: string | undefined): boolean => {
export const isBizId = (id: string | undefined): id is string => {
if (!id || !/^\d{13,19}$/.test(id)) return false
const snowflake = BigInt(id)