Expand fetching in some cases

This commit is contained in:
Eric Bailey
2025-06-09 17:39:52 -05:00
parent 5f2e17d690
commit 46160e9035
2 changed files with 38 additions and 4 deletions
+21 -1
View File
@@ -4,4 +4,24 @@ import {type AppBskyUnspeccedGetPostThreadV2} from '@atproto/api'
/**
* See the `below` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
*/
export const BELOW = 4
export const LINEAR_VIEW_BELOW = 10
/**
* See the `branchingFactor` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
*/
export const LINEAR_VIEW_BF = 1
/**
* See the `below` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
*/
export const TREE_VIEW_BELOW = 4
/**
* See the `branchingFactor` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
*/
export const TREE_VIEW_BF = undefined
/**
* See the `below` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
*/
export const TREE_VIEW_BELOW_DESKTOP = 6
+17 -3
View File
@@ -2,9 +2,16 @@ import {useCallback, useMemo, useState} from 'react'
import {useQuery, useQueryClient} from '@tanstack/react-query'
import {wait} from '#/lib/async/wait'
import {isWeb} from '#/platform/detection'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {useThreadPreferences} from '#/state/queries/preferences/useThreadPreferences'
import {BELOW} from '#/state/queries/usePostThread/const'
import {
LINEAR_VIEW_BELOW,
LINEAR_VIEW_BF,
TREE_VIEW_BELOW,
TREE_VIEW_BELOW_DESKTOP,
TREE_VIEW_BF,
} from '#/state/queries/usePostThread/const'
import {
createCacheMutator,
getThreadPlaceholder,
@@ -23,6 +30,7 @@ import {getThreadgateRecord} from '#/state/queries/usePostThread/utils'
import * as views from '#/state/queries/usePostThread/views'
import {useAgent, useSession} from '#/state/session'
import {useMergeThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
import {useBreakpoints} from '#/alf'
export * from '#/state/queries/usePostThread/types'
@@ -30,6 +38,7 @@ export function usePostThread({anchor}: {anchor?: string}) {
const qc = useQueryClient()
const agent = useAgent()
const {hasSession} = useSession()
const {gtPhone} = useBreakpoints()
const moderationOpts = useModerationOpts()
const mergeThreadgateHiddenReplies = useMergeThreadgateHiddenReplies()
const {
@@ -58,8 +67,13 @@ export function usePostThread({anchor}: {anchor?: string}) {
async queryFn(ctx) {
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
anchor: anchor!,
branchingFactor: view === 'linear' ? 1 : undefined,
below: BELOW,
branchingFactor: view === 'linear' ? LINEAR_VIEW_BF : TREE_VIEW_BF,
below:
view === 'linear'
? LINEAR_VIEW_BELOW
: isWeb && gtPhone
? TREE_VIEW_BELOW_DESKTOP
: TREE_VIEW_BELOW,
sort: sort,
prioritizeFollowedUsers: prioritizeFollowedUsers,
})