Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/platform/assets/composables/useUploadModelWizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { computed, ref, watch } from 'vue'
import { st } from '@/i18n'
import type { AssetMetadata } from '@/platform/assets/schemas/assetSchema'
import { assetService } from '@/platform/assets/services/assetService'
import { useAssetsStore } from '@/stores/assetsStore'

interface WizardData {
url: string
Expand All @@ -18,6 +19,7 @@ interface ModelTypeOption {
}

export function useUploadModelWizard(modelTypes: Ref<ModelTypeOption[]>) {
const assetsStore = useAssetsStore()
const currentStep = ref(1)
const isFetchingMetadata = ref(false)
const isUploading = ref(false)
Expand Down Expand Up @@ -143,6 +145,12 @@ export function useUploadModelWizard(modelTypes: Ref<ModelTypeOption[]>) {

uploadStatus.value = 'success'
currentStep.value = 3

// Refresh model caches for the uploaded model type
if (selectedModelType.value) {
await assetsStore.refreshModelsByType(selectedModelType.value)
}
Comment thread
DrJKL marked this conversation as resolved.
Outdated

return true
} catch (error) {
console.error('Failed to upload asset:', error)
Expand Down
32 changes: 28 additions & 4 deletions src/stores/assetsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,50 @@ export const useAssetsStore = defineStore('assets', () => {
}
}

/**
* Invalidate and refresh model assets for all node types that use a specific model category
* @param modelType The model category (e.g., 'checkpoints', 'loras')
*/
async function refreshModelsByType(modelType: string): Promise<void> {
const { useModelToNodeStore } = await import('./modelToNodeStore')
Comment thread
DrJKL marked this conversation as resolved.
Outdated
const modelToNodeStore = useModelToNodeStore()

// Get all node types that use this model category
const providers = modelToNodeStore.getAllNodeProviders(modelType)
if (!providers.length) return

// Refresh each node type's cache
await Promise.all(
providers.map((provider) =>
updateModelsForNodeType(provider.nodeDef.name)
)
)
}
Comment thread
DrJKL marked this conversation as resolved.
Outdated

return {
modelAssetsByNodeType,
modelLoadingByNodeType,
modelErrorByNodeType,
updateModelsForNodeType
updateModelsForNodeType,
refreshModelsByType
}
Comment thread
DrJKL marked this conversation as resolved.
Outdated
}

return {
modelAssetsByNodeType: shallowReactive(new Map<string, AssetItem[]>()),
modelLoadingByNodeType: shallowReactive(new Map<string, boolean>()),
modelErrorByNodeType: shallowReactive(new Map<string, Error | null>()),
updateModelsForNodeType: async () => []
updateModelsForNodeType: async () => [],
refreshModelsByType: async () => {}
}
}

const {
modelAssetsByNodeType,
modelLoadingByNodeType,
modelErrorByNodeType,
updateModelsForNodeType
updateModelsForNodeType,
refreshModelsByType
} = getModelState()

return {
Expand All @@ -369,6 +392,7 @@ export const useAssetsStore = defineStore('assets', () => {
modelAssetsByNodeType,
modelLoadingByNodeType,
modelErrorByNodeType,
updateModelsForNodeType
updateModelsForNodeType,
refreshModelsByType
}
})
Loading