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
+19 -2
View File
@@ -2,7 +2,7 @@
import fileSaver from 'file-saver';
const { saveAs } = fileSaver;
import { chats, user, settings } from '$lib/stores';
import { chats, user, settings, scrollPaginationEnabled, pageSkip, pageLimit } from '$lib/stores';
import {
archiveAllChats,
@@ -61,7 +61,12 @@
await createNewChat(localStorage.token, chat);
}
}
// loading all chats. disable pagination on scrol.
scrollPaginationEnabled.set(false);
// subsequent queries will calculate page size to rehydrate the ui.
// since every chat is already loaded, the calculation should now load all chats.
pageSkip.set(0);
pageLimit.set(-1);
await chats.set(await getChatList(localStorage.token));
};
@@ -77,6 +82,12 @@
await archiveAllChats(localStorage.token).catch((error) => {
toast.error(error);
});
// loading all chats. disable pagination on scrol.
scrollPaginationEnabled.set(false);
// subsequent queries will calculate page size to rehydrate the ui.
// since every chat is already loaded, the calculation should now load all chats.
pageSkip.set(0);
pageLimit.set(-1);
await chats.set(await getChatList(localStorage.token));
};
@@ -85,6 +96,12 @@
await deleteAllChats(localStorage.token).catch((error) => {
toast.error(error);
});
// loading all chats. disable pagination on scrol.
scrollPaginationEnabled.set(false);
// subsequent queries will calculate page size to rehydrate the ui.
// since every chat is already loaded, the calculation should now load all chats.
pageSkip.set(0);
pageLimit.set(-1);
await chats.set(await getChatList(localStorage.token));
};