mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-05 15:40:10 +00:00
[refactor] Move setting migrations to settingStore
Relocate runSettingMigrations() from GraphCanvas.vue to settingStore's loadSettingValues() method. This improves separation of concerns by keeping data migration logic within the store rather than coupling it to UI components. The migrations now run at the optimal time: after loading setting values from the server but before any settings are registered, ensuring proper initialization order and preventing potential race conditions. This change makes the architecture cleaner and more maintainable by centralizing all setting-related logic in the appropriate store.
This commit is contained in:
@@ -86,7 +86,6 @@ import { useSettingStore } from '@/stores/settingStore'
|
||||
import { useToastStore } from '@/stores/toastStore'
|
||||
import { useColorPaletteStore } from '@/stores/workspace/colorPaletteStore'
|
||||
import { useWorkspaceStore } from '@/stores/workspaceStore'
|
||||
import { runSettingMigrations } from '@/utils/migration/settingsMigration'
|
||||
|
||||
const emit = defineEmits<{
|
||||
ready: []
|
||||
@@ -299,9 +298,6 @@ onMounted(async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// Run cross-setting migrations
|
||||
await runSettingMigrations()
|
||||
|
||||
CORE_SETTINGS.forEach((setting) => {
|
||||
settingStore.addSetting(setting)
|
||||
})
|
||||
|
||||
@@ -7,6 +7,7 @@ import { api } from '@/scripts/api'
|
||||
import { app } from '@/scripts/app'
|
||||
import type { SettingParams } from '@/types/settingTypes'
|
||||
import type { TreeNode } from '@/types/treeExplorerTypes'
|
||||
import { runSettingMigrations } from '@/utils/migration/settingsMigration'
|
||||
|
||||
export const getSettingInfo = (setting: SettingParams) => {
|
||||
const parts = setting.category || setting.id.split('.')
|
||||
@@ -109,6 +110,9 @@ export const useSettingStore = defineStore('setting', () => {
|
||||
)
|
||||
}
|
||||
settingValues.value = await api.getSettings()
|
||||
|
||||
// Run migrations after loading values but before settings are registered
|
||||
await runSettingMigrations()
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user