Expand fetching in some cases
This commit is contained in:
@@ -4,4 +4,24 @@ import {type AppBskyUnspeccedGetPostThreadV2} from '@atproto/api'
|
|||||||
/**
|
/**
|
||||||
* See the `below` param on {@link AppBskyUnspeccedGetPostThreadV2.QueryParams}
|
* 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
|
||||||
|
|||||||
@@ -2,9 +2,16 @@ import {useCallback, useMemo, useState} from 'react'
|
|||||||
import {useQuery, useQueryClient} from '@tanstack/react-query'
|
import {useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {wait} from '#/lib/async/wait'
|
import {wait} from '#/lib/async/wait'
|
||||||
|
import {isWeb} from '#/platform/detection'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useThreadPreferences} from '#/state/queries/preferences/useThreadPreferences'
|
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 {
|
import {
|
||||||
createCacheMutator,
|
createCacheMutator,
|
||||||
getThreadPlaceholder,
|
getThreadPlaceholder,
|
||||||
@@ -23,6 +30,7 @@ import {getThreadgateRecord} from '#/state/queries/usePostThread/utils'
|
|||||||
import * as views from '#/state/queries/usePostThread/views'
|
import * as views from '#/state/queries/usePostThread/views'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useSession} from '#/state/session'
|
||||||
import {useMergeThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
import {useMergeThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
||||||
|
import {useBreakpoints} from '#/alf'
|
||||||
|
|
||||||
export * from '#/state/queries/usePostThread/types'
|
export * from '#/state/queries/usePostThread/types'
|
||||||
|
|
||||||
@@ -30,6 +38,7 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
|
const {gtPhone} = useBreakpoints()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const mergeThreadgateHiddenReplies = useMergeThreadgateHiddenReplies()
|
const mergeThreadgateHiddenReplies = useMergeThreadgateHiddenReplies()
|
||||||
const {
|
const {
|
||||||
@@ -58,8 +67,13 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
async queryFn(ctx) {
|
async queryFn(ctx) {
|
||||||
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
|
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
|
||||||
anchor: anchor!,
|
anchor: anchor!,
|
||||||
branchingFactor: view === 'linear' ? 1 : undefined,
|
branchingFactor: view === 'linear' ? LINEAR_VIEW_BF : TREE_VIEW_BF,
|
||||||
below: BELOW,
|
below:
|
||||||
|
view === 'linear'
|
||||||
|
? LINEAR_VIEW_BELOW
|
||||||
|
: isWeb && gtPhone
|
||||||
|
? TREE_VIEW_BELOW_DESKTOP
|
||||||
|
: TREE_VIEW_BELOW,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
prioritizeFollowedUsers: prioritizeFollowedUsers,
|
prioritizeFollowedUsers: prioritizeFollowedUsers,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user