@@ -54,8 +54,7 @@ export class CivitaiDownloaderUI {
5454 this . downloadModelTypeSelect = this . modal . querySelector ( '#civitai-model-type' ) ;
5555 this . createModelTypeButton = this . modal . querySelector ( '#civitai-create-model-type' ) ;
5656 this . customFilenameInput = this . modal . querySelector ( '#civitai-custom-filename' ) ;
57- this . subdirSelect = this . modal . querySelector ( '#civitai-subdir-select' ) ;
58- this . createSubdirButton = this . modal . querySelector ( '#civitai-create-subdir' ) ;
57+ this . customDownloadPathInput = this . modal . querySelector ( '#civitai-custom-download-path' ) ;
5958 this . downloadConnectionsInput = this . modal . querySelector ( '#civitai-connections' ) ;
6059 this . forceRedownloadCheckbox = this . modal . querySelector ( '#civitai-force-redownload' ) ;
6160 this . downloadSubmitButton = this . modal . querySelector ( '#civitai-download-submit' ) ;
@@ -88,6 +87,7 @@ export class CivitaiDownloaderUI {
8887 this . settingsApiKeyInput = this . modal . querySelector ( '#civitai-settings-api-key' ) ;
8988 this . settingsConnectionsInput = this . modal . querySelector ( '#civitai-settings-connections' ) ;
9089 this . settingsDefaultTypeSelect = this . modal . querySelector ( '#civitai-settings-default-type' ) ;
90+ this . settingsCustomPathInput = this . modal . querySelector ( '#civitai-settings-custom-path' ) ;
9191 this . settingsAutoOpenCheckbox = this . modal . querySelector ( '#civitai-settings-auto-open-status' ) ;
9292 this . settingsHideMatureCheckbox = this . modal . querySelector ( '#civitai-settings-hide-mature' ) ;
9393 this . settingsNsfwThresholdInput = this . modal . querySelector ( '#civitai-settings-nsfw-threshold' ) ;
@@ -120,7 +120,7 @@ export class CivitaiDownloaderUI {
120120 try {
121121 const types = await CivitaiDownloaderAPI . getModelTypes ( ) ;
122122 if ( ! types || typeof types !== 'object' || Object . keys ( types ) . length === 0 ) {
123- throw new Error ( "Received invalid model types data format." ) ;
123+ throw new Error ( "Received invalid model types data format." ) ;
124124 }
125125 this . modelTypes = types ;
126126 const sortedTypes = Object . entries ( this . modelTypes ) . sort ( ( a , b ) => a [ 1 ] . localeCompare ( b [ 1 ] ) ) ;
@@ -133,12 +133,10 @@ export class CivitaiDownloaderUI {
133133 const option = document . createElement ( 'option' ) ;
134134 option . value = key ;
135135 option . textContent = displayName ;
136- this . downloadModelTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
137- this . settingsDefaultTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
138- this . searchTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
139- } ) ;
140- // After types are populated, load subdirs for the current selection
141- await this . loadAndPopulateSubdirs ( this . downloadModelTypeSelect . value ) ;
136+ this . downloadModelTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
137+ this . settingsDefaultTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
138+ this . searchTypeSelect . appendChild ( option . cloneNode ( true ) ) ;
139+ } ) ;
142140 } catch ( error ) {
143141 console . error ( "[Civicomfy] Failed to get or populate model types:" , error ) ;
144142 this . showToast ( 'Failed to load model types' , 'error' ) ;
@@ -147,38 +145,6 @@ export class CivitaiDownloaderUI {
147145 }
148146 }
149147
150- async loadAndPopulateSubdirs ( modelType ) {
151- try {
152- const res = await CivitaiDownloaderAPI . getModelDirs ( modelType ) ;
153- const select = this . subdirSelect ;
154- if ( ! select ) return ;
155- const current = select . value ;
156- select . innerHTML = '' ;
157- const optRoot = document . createElement ( 'option' ) ;
158- optRoot . value = '' ;
159- optRoot . textContent = '(root)' ;
160- select . appendChild ( optRoot ) ;
161- if ( res && Array . isArray ( res . subdirs ) ) {
162- // res.subdirs contains '' for root; skip empty since we added (root)
163- res . subdirs . filter ( p => p && typeof p === 'string' ) . forEach ( rel => {
164- const opt = document . createElement ( 'option' ) ;
165- opt . value = rel ;
166- opt . textContent = rel ;
167- select . appendChild ( opt ) ;
168- } ) ;
169- }
170- // Restore selection if still present
171- if ( Array . from ( select . options ) . some ( o => o . value === current ) ) {
172- select . value = current ;
173- }
174- } catch ( e ) {
175- console . error ( '[Civicomfy] Failed to load subdirectories:' , e ) ;
176- if ( this . subdirSelect ) {
177- this . subdirSelect . innerHTML = '<option value="">(root)</option>' ;
178- }
179- }
180- }
181-
182148 // (loadAndPopulateRoots removed; dynamic types already reflect models/ subfolders)
183149
184150 async populateBaseModels ( ) {
@@ -198,8 +164,8 @@ export class CivitaiDownloaderUI {
198164 this . searchBaseModelSelect . appendChild ( option ) ;
199165 } ) ;
200166 } catch ( error ) {
201- console . error ( "[Civicomfy] Failed to get or populate base models:" , error ) ;
202- this . showToast ( 'Failed to load base models list' , 'error' ) ;
167+ console . error ( "[Civicomfy] Failed to get or populate base models:" , error ) ;
168+ this . showToast ( 'Failed to load base models list' , 'error' ) ;
203169 }
204170 }
205171
@@ -216,11 +182,14 @@ export class CivitaiDownloaderUI {
216182
217183 if ( tabId === 'status' ) this . updateStatus ( ) ;
218184 else if ( tabId === 'settings' ) this . applySettings ( ) ;
219- else if ( tabId === 'download' ) {
185+ else if ( tabId === 'download' ) {
220186 this . downloadConnectionsInput . value = this . settings . numConnections ;
221187 if ( Object . keys ( this . modelTypes ) . length > 0 ) {
222188 this . downloadModelTypeSelect . value = this . settings . defaultModelType ;
223189 }
190+ if ( this . customDownloadPathInput ) {
191+ this . customDownloadPathInput . value = this . settings . customDownloadPath || '' ;
192+ }
224193 }
225194 }
226195
@@ -280,7 +249,7 @@ export class CivitaiDownloaderUI {
280249 renderDownloadList = ( items , container , emptyMessage ) => renderDownloadList ( this , items , container , emptyMessage ) ;
281250 renderSearchResults = ( items ) => renderSearchResults ( this , items ) ;
282251 renderDownloadPreview = ( data ) => renderDownloadPreview ( this , data ) ;
283-
252+
284253 // --- Auto-select model type based on Civitai model type ---
285254 inferFolderFromCivitaiType ( civitaiType ) {
286255 if ( ! civitaiType || typeof civitaiType !== 'string' ) return null ;
@@ -358,9 +327,6 @@ export class CivitaiDownloaderUI {
358327 if ( ! folder ) return ;
359328 if ( this . downloadModelTypeSelect && this . downloadModelTypeSelect . value !== folder ) {
360329 this . downloadModelTypeSelect . value = folder ;
361- await this . loadAndPopulateSubdirs ( folder ) ;
362- // Reset subdir to root after auto-switch
363- if ( this . subdirSelect ) this . subdirSelect . value = '' ;
364330 }
365331 } catch ( e ) {
366332 console . warn ( '[Civicomfy] Auto-select model type failed:' , e ) ;
@@ -390,7 +356,7 @@ export class CivitaiDownloaderUI {
390356
391357 const fragment = document . createDocumentFragment ( ) ;
392358 fragment . appendChild ( createButton ( '« Prev' , currentPage - 1 , currentPage === 1 ) ) ;
393-
359+
394360 let startPage = Math . max ( 1 , currentPage - 2 ) ;
395361 let endPage = Math . min ( totalPages , currentPage + 2 ) ;
396362
@@ -403,7 +369,7 @@ export class CivitaiDownloaderUI {
403369
404370 if ( endPage < totalPages - 1 ) fragment . appendChild ( document . createElement ( 'span' ) ) . textContent = '...' ;
405371 if ( endPage < totalPages ) fragment . appendChild ( createButton ( totalPages , totalPages ) ) ;
406-
372+
407373 fragment . appendChild ( createButton ( 'Next »' , currentPage + 1 , currentPage === totalPages ) ) ;
408374
409375 const info = document . createElement ( 'div' ) ;
0 commit comments