feat: airdrop chats between windows

This commit is contained in:
Timothy J. Baek
2024-10-26 21:25:48 -07:00
parent e6ca994c92
commit effcbd6301
4 changed files with 70 additions and 44 deletions
+18 -20
View File
@@ -571,10 +571,15 @@
importChatHandler(e.detail, true);
}}
on:drop={async (e) => {
const { type, id } = e.detail;
const { type, id, item } = e.detail;
if (type === 'chat') {
const chat = await getChatById(localStorage.token, id);
let chat = await getChatById(localStorage.token, id).catch((error) => {
return null;
});
if (!chat && item) {
chat = await importChat(localStorage.token, item.chat, item?.meta ?? {});
}
if (chat) {
console.log(chat);
@@ -587,19 +592,13 @@
toast.error(error);
return null;
});
if (res) {
initChatList();
}
}
if (!chat.pinned) {
const res = await toggleChatPinnedStatusById(localStorage.token, id);
if (res) {
initChatList();
}
}
initChatList();
}
}
}}
@@ -660,10 +659,15 @@
importChatHandler(e.detail);
}}
on:drop={async (e) => {
const { type, id } = e.detail;
const { type, id, item } = e.detail;
if (type === 'chat') {
const chat = await getChatById(localStorage.token, id);
let chat = await getChatById(localStorage.token, id).catch((error) => {
return null;
});
if (!chat && item) {
chat = await importChat(localStorage.token, item.chat, item?.meta ?? {});
}
if (chat) {
console.log(chat);
@@ -674,19 +678,13 @@
return null;
}
);
if (res) {
initChatList();
}
}
if (chat.pinned) {
const res = await toggleChatPinnedStatusById(localStorage.token, id);
if (res) {
initChatList();
}
}
initChatList();
}
} else if (type === 'folder') {
if (folders[id].parent_id === null) {