1
1
import { $el } from "../ui.js" ;
2
2
import { api } from "../api.js" ;
3
3
import { ComfyDialog } from "./dialog.js" ;
4
+ import type { ComfyApp } from "../app.js" ;
5
+
6
+ interface Setting {
7
+ id : string ;
8
+ onChange ?: ( value : any , oldValue ?: any ) => void ;
9
+ name : string ;
10
+ render : ( ) => HTMLElement ;
11
+ }
4
12
5
13
export class ComfySettingsDialog extends ComfyDialog {
14
+ app : ComfyApp ;
15
+ settingsValues : any ;
16
+ settingsLookup : Record < string , Setting > ;
17
+ declare element : HTMLDialogElement ;
18
+
6
19
constructor ( app ) {
7
20
super ( ) ;
8
21
this . app = app ;
@@ -40,7 +53,7 @@ export class ComfySettingsDialog extends ComfyDialog {
40
53
} ) ,
41
54
] ) ,
42
55
]
43
- ) ;
56
+ ) as HTMLDialogElement ;
44
57
}
45
58
46
59
get settings ( ) {
@@ -67,10 +80,10 @@ export class ComfySettingsDialog extends ComfyDialog {
67
80
return id ;
68
81
}
69
82
70
- getSettingValue ( id , defaultValue ) {
83
+ getSettingValue ( id , defaultValue ? ) {
71
84
let value = this . settingsValues [ this . getId ( id ) ] ;
72
- if ( value != null ) {
73
- if ( this . app . storageLocation === "browser" ) {
85
+ if ( value != null ) {
86
+ if ( this . app . storageLocation === "browser" ) {
74
87
try {
75
88
value = JSON . parse ( value ) ;
76
89
} catch ( error ) {
@@ -288,7 +301,7 @@ export class ComfySettingsDialog extends ComfyDialog {
288
301
289
302
return element ;
290
303
} ,
291
- } ;
304
+ } as Setting ;
292
305
293
306
const self = this ;
294
307
return {
@@ -308,6 +321,8 @@ export class ComfySettingsDialog extends ComfyDialog {
308
321
{
309
322
style : { display : "none" } ,
310
323
} ,
324
+ // TODO remove this once ui.js is migrated.
325
+ // @ts -ignore
311
326
[ $el ( "th" ) , $el ( "th" , { style : { width : "33%" } } ) ]
312
327
) ,
313
328
...this . settings . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) . map ( ( s ) => s . render ( ) )
0 commit comments