From 74d96f86105561dd24d62c4b9be5c13621fd65d0 Mon Sep 17 00:00:00 2001 From: Christian Bastian Date: Sat, 27 Jan 2024 21:25:37 -0500 Subject: [PATCH] Dropdown optional model type virtual directory --- web/model-manager.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/web/model-manager.js b/web/model-manager.js index 7ec51e7..59c69cc 100644 --- a/web/model-manager.js +++ b/web/model-manager.js @@ -155,10 +155,10 @@ class DirectoryDropdown { /** * @param {DirectoryItem[]} directories - * @param {string} modelType * @param {string} sep + * @param {string} [modelType = ""] */ - update(directories, modelType, sep) { + update(directories, sep, modelType = "") { const dropdown = this.element; const input = this.#input; const submitSearch = this.#submitSearch; @@ -169,15 +169,18 @@ class DirectoryDropdown { return; } - let cwd = null; - const root = directories[0]; - const rootChildIndex = root["childIndex"]; - const rootChildCount = root["childCount"]; - for (let i = rootChildIndex; i < rootChildIndex + rootChildCount; i++) { - const modelDir = directories[i]; - if (modelDir["name"] === modelType) { - cwd = i; - break; + let cwd = 0; + if (modelType !== "") { + const root = directories[0]; + const rootChildIndex = root["childIndex"]; + const rootChildCount = root["childCount"]; + cwd = null; + for (let i = rootChildIndex; i < rootChildIndex + rootChildCount; i++) { + const modelDir = directories[i]; + if (modelDir["name"] === modelType) { + cwd = i; + break; + } } } @@ -1220,8 +1223,8 @@ class ModelManager extends ComfyDialog { const modelType = this.#el.modelTypeSelect.value; this.#modelContentFilterDirectoryDropdown.update( this.#data.modelDirectories, - modelType, this.#sep, + modelType, ); const value = this.#el.modelContentFilter.value; this.#data.previousModelFilters[modelType] = value;