[Chat] Set the default listConvos limit to 10 (#10448)
This commit is contained in:
@@ -21,12 +21,15 @@ import {useAgent, useSession} from '#/state/session'
|
|||||||
import {parseConvoView} from '#/components/dms/util'
|
import {parseConvoView} from '#/components/dms/util'
|
||||||
import {useLeftConvos} from './leave-conversation'
|
import {useLeftConvos} from './leave-conversation'
|
||||||
|
|
||||||
|
const DEFAULT_LIMIT = 10
|
||||||
|
|
||||||
export const RQKEY_ROOT = 'convo-list'
|
export const RQKEY_ROOT = 'convo-list'
|
||||||
export const RQKEY = (
|
export const RQKEY = (
|
||||||
status: 'accepted' | 'request' | 'all',
|
status: 'accepted' | 'request' | 'all',
|
||||||
readState: 'all' | 'unread' = 'all',
|
readState: 'all' | 'unread' = 'all',
|
||||||
kind: 'all' | 'group' | 'direct' = 'all',
|
kind: 'all' | 'group' | 'direct' = 'all',
|
||||||
) => [RQKEY_ROOT, status, readState, kind]
|
limit?: number,
|
||||||
|
) => [RQKEY_ROOT, status, readState, kind, limit]
|
||||||
type RQPageParam = string | undefined
|
type RQPageParam = string | undefined
|
||||||
|
|
||||||
export function useListConvosQuery({
|
export function useListConvosQuery({
|
||||||
@@ -34,21 +37,23 @@ export function useListConvosQuery({
|
|||||||
status,
|
status,
|
||||||
readState = 'all',
|
readState = 'all',
|
||||||
kind = 'all',
|
kind = 'all',
|
||||||
|
limit = DEFAULT_LIMIT,
|
||||||
}: {
|
}: {
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
status?: 'request' | 'accepted'
|
status?: 'request' | 'accepted'
|
||||||
readState?: 'all' | 'unread'
|
readState?: 'all' | 'unread'
|
||||||
kind?: 'all' | 'group' | 'direct'
|
kind?: 'all' | 'group' | 'direct'
|
||||||
|
limit?: number
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
|
|
||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
enabled,
|
enabled,
|
||||||
queryKey: RQKEY(status ?? 'all', readState),
|
queryKey: RQKEY(status ?? 'all', readState, kind, limit),
|
||||||
queryFn: async ({pageParam}) => {
|
queryFn: async ({pageParam}) => {
|
||||||
const {data} = await agent.chat.bsky.convo.listConvos(
|
const {data} = await agent.chat.bsky.convo.listConvos(
|
||||||
{
|
{
|
||||||
limit: 20,
|
limit,
|
||||||
cursor: pageParam,
|
cursor: pageParam,
|
||||||
readState: readState === 'unread' ? 'unread' : undefined,
|
readState: readState === 'unread' ? 'unread' : undefined,
|
||||||
kind: kind === 'all' ? undefined : kind,
|
kind: kind === 'all' ? undefined : kind,
|
||||||
@@ -97,7 +102,7 @@ export function ListConvosProviderInner({
|
|||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
}) {
|
}) {
|
||||||
const {refetch, data} = useListConvosQuery({readState: 'unread'})
|
const {refetch, data} = useListConvosQuery({readState: 'unread', limit: 20})
|
||||||
const messagesBus = useMessagesEventBus()
|
const messagesBus = useMessagesEventBus()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const {currentConvoId} = useCurrentConvoId()
|
const {currentConvoId} = useCurrentConvoId()
|
||||||
|
|||||||
Reference in New Issue
Block a user