refactor trpc procedures into domains
This commit is contained in:
@@ -40,7 +40,7 @@ export default function LayoutDefault({
|
||||
const conversationId = useStore((state) => state.selectedConversationId);
|
||||
|
||||
useEffect(() => {
|
||||
trpc.chat.listConversations.query().then((res) => {
|
||||
trpc.chat.conversations.fetchAll.query().then((res) => {
|
||||
setConversations(res);
|
||||
});
|
||||
}, [setConversations]);
|
||||
@@ -55,8 +55,8 @@ export default function LayoutDefault({
|
||||
|
||||
async function handleDeleteConversation(conversationId: string) {
|
||||
removeConversation(conversationId);
|
||||
await trpc.chat.deleteConversation.mutate({ id: conversationId });
|
||||
const res = await trpc.chat.createConversation.mutate();
|
||||
await trpc.chat.conversations.deleteOne.mutate({ id: conversationId });
|
||||
const res = await trpc.chat.conversations.start.mutate();
|
||||
if (!res?.id) return;
|
||||
addConversation(res);
|
||||
await navigate(`/chat/${res.id}`);
|
||||
@@ -108,7 +108,7 @@ export default function LayoutDefault({
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
trpc.chat.createConversation.mutate().then((res) => {
|
||||
trpc.chat.conversations.start.mutate().then((res) => {
|
||||
if (!res?.id) return;
|
||||
addConversation(res);
|
||||
navigate(`/chat/${res.id}`);
|
||||
|
||||
Reference in New Issue
Block a user