brutalism design
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { ChatMessage, ResponseError } from '@shared/api/generated-chad-api.ts'
|
||||
import type { InfiniteData, QueryKey } from '@tanstack/vue-query'
|
||||
import type { QueryKey } from '@tanstack/vue-query'
|
||||
import api from '@shared/api/client.ts'
|
||||
import { useInfiniteQuery } from '@tanstack/vue-query'
|
||||
|
||||
@@ -10,10 +10,10 @@ interface Response {
|
||||
type PageParam = string | undefined
|
||||
|
||||
export function qChatMessages() {
|
||||
return useInfiniteQuery<Response, ResponseError, InfiniteData<Response, PageParam>, QueryKey, PageParam>({
|
||||
return useInfiniteQuery<Response, ResponseError, ChatMessage[], QueryKey, PageParam>({
|
||||
queryKey: ['chat-messages'],
|
||||
queryFn: async ({ pageParam }) => {
|
||||
const response = await api.chad.chatMessages({ cursor: pageParam, limit: 30 })
|
||||
const response = await api.chad.chatMessages({ cursor: pageParam, limit: 25 })
|
||||
|
||||
return response.data
|
||||
// return {
|
||||
@@ -25,6 +25,9 @@ export function qChatMessages() {
|
||||
// pages: [...data.pages].reverse(),
|
||||
// pageParams: [...data.pageParams].reverse(),
|
||||
// }),
|
||||
select: (data) => {
|
||||
return data.pages.flatMap(page => page.messages).toReversed()
|
||||
},
|
||||
initialPageParam: undefined,
|
||||
getNextPageParam: (lastPage) => {
|
||||
return lastPage.nextCursor
|
||||
|
||||
Reference in New Issue
Block a user