refac: chatlist skip, limit -> page

This commit is contained in:
Timothy J. Baek
2024-08-04 16:58:08 +02:00
parent a2f9f7c975
commit a084938d9c
10 changed files with 72 additions and 74 deletions

View File

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