enhancement: added loading state for conversation

This commit is contained in:
JeevaRamanathan M
2024-10-19 04:24:14 +00:00
parent 7bf79675c1
commit 2366c2cd94
3 changed files with 32 additions and 12 deletions

View File

@@ -21,9 +21,10 @@ export async function getDocs(): Promise<Doc[] | null> {
}
}
export async function getConversations(): Promise<
{ name: string; id: string }[] | null
> {
export async function getConversations(): Promise<{
data: { name: string; id: string }[] | null;
loading: boolean;
}> {
try {
const response = await conversationService.getConversations();
const data = await response.json();
@@ -34,10 +35,10 @@ export async function getConversations(): Promise<
conversations.push(conversation as { name: string; id: string });
});
return conversations;
return { data: conversations, loading: false };
} catch (error) {
console.log(error);
return null;
return { data: null, loading: false };
}
}