fix(desktop): prefetch entry detail for entry not exist
This commit is contained in:
parent
84c84d8d60
commit
649f623e7d
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in New Issue