[Refactor] Rework modelStore and ModelLibrarySidebarTab (#1350)

* nit

* Rename

* nit

* Move load model folders to app level

* Various fixes

* nit

* nit

* wip

* nit

* nit

* nit

* Split

* nit

* Add back spinner

* nit

* nit

* Add refresh button

* nit

* nit

* Preserve model folder order

* Avoid order change on folder open
This commit is contained in:
Chenlei Hu
2024-10-28 21:23:53 -04:00
committed by GitHub
parent 757f0ced81
commit 4582c71583
8 changed files with 162 additions and 148 deletions

View File

@@ -366,7 +366,10 @@ class ComfyApi extends EventTarget {
if (res.status === 404) {
return []
}
return await res.json()
const folderBlacklist = ['configs', 'custom_nodes']
return (await res.json()).filter(
(folder: string) => !folderBlacklist.includes(folder)
)
}
/**
@@ -374,10 +377,10 @@ class ComfyApi extends EventTarget {
* @param {string} folder The folder to list models from, such as 'checkpoints'
* @returns The list of model filenames within the specified folder
*/
async getModels(folder: string) {
async getModels(folder: string): Promise<string[]> {
const res = await this.fetchApi(`/models/${folder}`)
if (res.status === 404) {
return null
return []
}
return await res.json()
}