[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:
Benjamin Lu
2025-07-01 19:19:51 -04:00
parent 6def711414
commit c5edbe588c
2 changed files with 4 additions and 4 deletions

View File

@@ -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)
})

View File

@@ -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 {