diff --git a/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryLayoutContent.tsx b/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryLayoutContent.tsx index 12656ee09..4e85d6919 100644 --- a/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryLayoutContent.tsx +++ b/apps/desktop/layer/renderer/src/modules/app-layout/entry-content/EntryLayoutContent.tsx @@ -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() diff --git a/packages/internal/store/src/entry/hooks.ts b/packages/internal/store/src/entry/hooks.ts index 81f95c367..f73074bcc 100644 --- a/packages/internal/store/src/entry/hooks.ts +++ b/packages/internal/store/src/entry/hooks.ts @@ -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), diff --git a/packages/internal/store/src/entry/store.ts b/packages/internal/store/src/entry/store.ts index bc768e483..6af8e50a7 100644 --- a/packages/internal/store/src/entry/store.ts +++ b/packages/internal/store/src/entry/store.ts @@ -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 diff --git a/packages/internal/utils/src/utils.ts b/packages/internal/utils/src/utils.ts index ba79722ad..beb81ede9 100644 --- a/packages/internal/utils/src/utils.ts +++ b/packages/internal/utils/src/utils.ts @@ -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)