retaining original state

This commit is contained in:
JeevaRamanathan M
2024-10-19 04:45:00 +00:00
parent 2366c2cd94
commit a185b2a12a

View File

@@ -96,14 +96,14 @@ export default function Navigation({ navOpen, setNavOpen }: NavigationProps) {
}, [conversations?.data, dispatch]);
async function fetchConversations() {
dispatch(setConversations({ data: null, loading: true }));
dispatch(setConversations({ ...conversations, loading: true }));
return await getConversations()
.then((fetchedConversations) => {
dispatch(setConversations(fetchedConversations));
})
.catch((error) => {
console.error('Failed to fetch conversations: ', error);
dispatch(setConversations({ data: null, loading: false }));
dispatch(setConversations({ ...conversations, loading: false }));
});
}