[Clipclops] Header for chat (#3775)
* add temp `getchat` query * properly get the other profile * add basic header * normalize layout on all devices * remove unused imports, adjust style * remove unnecessary log * remove another log * remove some more imports * cleanup * use `Button` instead in the header * lint
This commit is contained in:
@@ -73,6 +73,8 @@ export function useChat(chatId: string) {
|
||||
const chatJson =
|
||||
(await chatResponse.json()) as TempDmChatGetChat.OutputSchema
|
||||
|
||||
queryClient.setQueryData(['chatQuery', chatId], chatJson.chat)
|
||||
|
||||
const newChat = {
|
||||
chatId,
|
||||
messages: messagesJson.messages,
|
||||
@@ -275,3 +277,25 @@ export function useListChats() {
|
||||
getNextPageParam: lastPage => lastPage.cursor,
|
||||
})
|
||||
}
|
||||
|
||||
export function useChatQuery(chatId: string) {
|
||||
const headers = useHeaders()
|
||||
const {serviceUrl} = useDmServiceUrlStorage()
|
||||
|
||||
return useQuery({
|
||||
queryKey: ['chatQuery', chatId],
|
||||
queryFn: async () => {
|
||||
const chatResponse = await fetch(
|
||||
`${serviceUrl}/xrpc/temp.dm.getChat?chatId=${chatId}`,
|
||||
{
|
||||
headers,
|
||||
},
|
||||
)
|
||||
|
||||
if (!chatResponse.ok) throw new Error('Failed to fetch chat')
|
||||
|
||||
const json = (await chatResponse.json()) as TempDmChatGetChat.OutputSchema
|
||||
return json.chat
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user