refac
This commit is contained in:
@@ -61,30 +61,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const importChatsHandler = async (_chats) => {
|
const importChatsHandler = async (_chats) => {
|
||||||
const chats = _chats.map((chat) => {
|
const res = await importChats(
|
||||||
if (chat.chat) {
|
localStorage.token,
|
||||||
return {
|
_chats.map((chat) => {
|
||||||
chat: chat.chat,
|
if (chat.chat) {
|
||||||
meta: chat.meta ?? {},
|
return {
|
||||||
pinned: false,
|
chat: chat.chat,
|
||||||
folder_id: chat?.folder_id ?? null,
|
meta: chat.meta ?? {},
|
||||||
created_at: chat?.created_at ?? null,
|
pinned: false,
|
||||||
updated_at: chat?.updated_at ?? null
|
folder_id: chat?.folder_id ?? null,
|
||||||
};
|
created_at: chat?.created_at ?? null,
|
||||||
} else {
|
updated_at: chat?.updated_at ?? null
|
||||||
// Legacy format
|
};
|
||||||
return {
|
} else {
|
||||||
chat: chat,
|
// Legacy format
|
||||||
meta: {},
|
return {
|
||||||
pinned: false,
|
chat: chat,
|
||||||
folder_id: null,
|
meta: {},
|
||||||
created_at: chat?.created_at ?? null,
|
pinned: false,
|
||||||
updated_at: chat?.updated_at ?? null
|
folder_id: null,
|
||||||
};
|
created_at: chat?.created_at ?? null,
|
||||||
}
|
updated_at: chat?.updated_at ?? null
|
||||||
});
|
};
|
||||||
|
}
|
||||||
const res = await importChats(localStorage.token, chats);
|
})
|
||||||
|
);
|
||||||
if (res) {
|
if (res) {
|
||||||
toast.success(`Successfully imported ${res.length} chats.`);
|
toast.success(`Successfully imported ${res.length} chats.`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user