refac
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
temporaryChatEnabled,
|
||||
selectedFolder
|
||||
} from '$lib/stores';
|
||||
import { refreshChatList } from '$lib/stores/chatList';
|
||||
import { refreshChatList, refreshFolderChatLists } from '$lib/stores/chatList';
|
||||
import { sanitizeResponseContent, extractCurlyBraceWords } from '$lib/utils';
|
||||
import { WEBUI_API_BASE_URL, WEBUI_BASE_URL } from '$lib/constants';
|
||||
|
||||
@@ -112,11 +112,11 @@
|
||||
<FolderTitle
|
||||
folder={$selectedFolder}
|
||||
readOnly={folderReadOnly}
|
||||
onUpdate={async (folder) => {
|
||||
await refreshChatList(localStorage.token);
|
||||
onUpdate={async () => {
|
||||
await Promise.all([refreshChatList(localStorage.token), refreshFolderChatLists()]);
|
||||
}}
|
||||
onDelete={async () => {
|
||||
await refreshChatList(localStorage.token);
|
||||
await Promise.all([refreshChatList(localStorage.token), refreshFolderChatLists()]);
|
||||
|
||||
selectedFolder.set(null);
|
||||
}}
|
||||
|
||||
@@ -701,7 +701,7 @@
|
||||
socketInstance?.on('events', chatActiveEventHandler);
|
||||
socketInstance?.on('connect', refreshChatRows);
|
||||
|
||||
const unregisterFolderRefreshHandler = registerFolderRefreshHandler((folderId, chat) => {
|
||||
const unregisterFolderRefreshHandler = registerFolderRefreshHandler(async (folderId, chat) => {
|
||||
if (folderId) {
|
||||
if (chat) {
|
||||
return folderRegistry[folderId]?.upsertChat?.(chat);
|
||||
@@ -710,6 +710,7 @@
|
||||
return folderRegistry[folderId]?.setFolderItems?.();
|
||||
}
|
||||
|
||||
await initFolders();
|
||||
return Promise.all(Object.values(folderRegistry).map((folder) => folder?.setFolderItems?.()));
|
||||
});
|
||||
|
||||
|
||||
@@ -61,10 +61,7 @@ export const refreshChatList = async (
|
||||
return { accepted: true, allLoaded };
|
||||
};
|
||||
|
||||
// The sidebar's folders keep their chat lists in local component state, refreshed
|
||||
// through a registry of per-folder callbacks that only the sidebar can reach.
|
||||
// Handlers registered here let other components (e.g. the open chat's menu)
|
||||
// request that refresh without a reference to the sidebar.
|
||||
// The sidebar owns folder state. This bridge lets other components refresh it.
|
||||
type FolderRefreshHandler = (folderId?: string | null, chat?: ChatListItem | null) => unknown;
|
||||
const folderRefreshHandlers = new Set<FolderRefreshHandler>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user