Skip to content

Commit

Permalink
pepper in some reactive
Browse files Browse the repository at this point in the history
the inner ModelStore (per-folder) can't be pinia because its made of temporary instances, but it can be reactive
  • Loading branch information
mcmonkey4eva committed Aug 29, 2024
1 parent 6609de5 commit 26eeb59
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/stores/modelStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { api } from '@/scripts/api'
import { defineStore } from 'pinia'
import { reactive } from 'vue'

/** (Internal helper) finds a value in a metadata object from any of a list of keys. */
function _findInMetadata(metadata: any, ...keys: string[]): string | null {
Expand Down Expand Up @@ -95,11 +96,17 @@ export class ComfyModelDef {

/** Model store for a folder */
export class ModelStore {
models: Record<string, ComfyModelDef> = {}
models: Record<string, ComfyModelDef> = reactive({})

constructor(directory: string, models: string[]) {
for (const model of models) {
this.models[model] = new ComfyModelDef(model, directory)
this.models[model] = reactive(new ComfyModelDef(model, directory))
}
}

async loadModelMetadata(modelName: string) {
if (this.models[modelName]) {
await this.models[modelName].load()
}
}
}
Expand All @@ -119,7 +126,7 @@ export const useModelStore = defineStore('modelStore', {
if (!models) {
return null
}
const store = new ModelStore(folder, models)
const store = reactive(new ModelStore(folder, models))
this.modelStoreMap[folder] = store
return store
},
Expand Down

0 comments on commit 26eeb59

Please sign in to comment.