refactor: uses of chats.set(...) support pagi sidebar

This commit is contained in:
Aryan Kothari
2024-08-01 15:20:36 -04:00
parent 62dc486c85
commit 2c4bc7a2b2
5 changed files with 70 additions and 19 deletions

View File

@@ -14,7 +14,15 @@
getChatListByTagName,
updateChatById
} from '$lib/apis/chats';
import { chatId, chats, mobile, pinnedChats, showSidebar } from '$lib/stores';
import {
chatId,
chats,
mobile,
pageSkip,
pageLimit,
pinnedChats,
showSidebar
} from '$lib/stores';
import ChatMenu from './ChatMenu.svelte';
import ShareChatModal from '$lib/components/chat/ShareChatModal.svelte';
@@ -40,7 +48,9 @@
await updateChatById(localStorage.token, id, {
title: _title
});
await chats.set(await getChatList(localStorage.token));
await chats.set(
await getChatList(localStorage.token, 0, $pageSkip * $pageLimit || $pageLimit)
);
await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned'));
}
};
@@ -53,14 +63,16 @@
if (res) {
goto(`/c/${res.id}`);
await chats.set(await getChatList(localStorage.token));
await chats.set(
await getChatList(localStorage.token, 0, $pageSkip * $pageLimit || $pageLimit)
);
await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned'));
}
};
const archiveChatHandler = async (id) => {
await archiveChatById(localStorage.token, id);
await chats.set(await getChatList(localStorage.token));
await chats.set(await getChatList(localStorage.token, 0, $pageSkip * $pageLimit || $pageLimit));
await pinnedChats.set(await getChatListByTagName(localStorage.token, 'pinned'));
};