21 lines
387 B
TypeScript
21 lines
387 B
TypeScript
import { useQuery } from "blitz";
|
|
|
|
import getConversationsQuery from "../queries/get-conversations";
|
|
|
|
export default function useConversation(recipient: string) {
|
|
return useQuery(
|
|
getConversationsQuery,
|
|
{},
|
|
{
|
|
select(conversations) {
|
|
if (!conversations[recipient]) {
|
|
return null;
|
|
}
|
|
|
|
return conversations[recipient]!;
|
|
},
|
|
keepPreviousData: true,
|
|
},
|
|
);
|
|
}
|