feat: add setMany to settingStore for batch setting updates (#8767)

## Summary
- Adds `setMany()` method to `settingStore` for updating multiple
settings in a single API call via the existing `storeSettings` endpoint
- Extracts shared setting-apply logic (`applySettingLocally`) to reduce
duplication between `set()` and `setMany()`
- Migrates all call sites where multiple settings were updated
sequentially to use `setMany()`

## Call sites updated
- `releaseStore.ts` — `handleSkipRelease`, `handleShowChangelog`,
`handleWhatsNewSeen` (3 settings each)
- `keybindingService.ts` — `persistUserKeybindings` (2 settings)
- `coreSettings.ts` — `NavigationMode.onChange` (2 settings)

## Test plan
- [x] Unit tests for `setMany` (batch update, skip unchanged, no-op when
unchanged)
- [x] Updated `releaseStore.test.ts` assertions to verify `setMany`
usage
- [x] Updated `useCoreCommands.test.ts` mock to include `setMany`
- [x] All existing tests pass
- [x] `pnpm typecheck`, `pnpm lint`, `pnpm format` pass

Fixes #1079

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-8767-feat-add-setMany-to-settingStore-for-batch-setting-updates-3036d73d36508161b8b6d298e1be1b7a)
by [Unito](https://www.unito.io)
This commit is contained in:
Johnpaul Chiwetelu
2026-02-10 13:47:53 +01:00
committed by GitHub
parent 061e96e488
commit 0288ea5b39
9 changed files with 178 additions and 70 deletions

View File

@@ -46,8 +46,9 @@ vi.mock('@/platform/settings/settingStore', () => {
return null
})
const set = vi.fn()
const setMany = vi.fn()
return {
useSettingStore: () => ({ get, set })
useSettingStore: () => ({ get, set, setMany })
}
})
@@ -534,18 +535,11 @@ describe('useReleaseStore', () => {
const settingStore = useSettingStore()
await store.handleSkipRelease('1.2.0')
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Version',
'1.2.0'
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Status',
'skipped'
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Timestamp',
expect.any(Number)
)
expect(settingStore.setMany).toHaveBeenCalledWith({
'Comfy.Release.Version': '1.2.0',
'Comfy.Release.Status': 'skipped',
'Comfy.Release.Timestamp': expect.any(Number)
})
})
it('should handle show changelog', async () => {
@@ -554,18 +548,11 @@ describe('useReleaseStore', () => {
const settingStore = useSettingStore()
await store.handleShowChangelog('1.2.0')
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Version',
'1.2.0'
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Status',
'changelog seen'
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Timestamp',
expect.any(Number)
)
expect(settingStore.setMany).toHaveBeenCalledWith({
'Comfy.Release.Version': '1.2.0',
'Comfy.Release.Status': 'changelog seen',
'Comfy.Release.Timestamp': expect.any(Number)
})
})
it('should handle whats new seen', async () => {
@@ -574,18 +561,11 @@ describe('useReleaseStore', () => {
const settingStore = useSettingStore()
await store.handleWhatsNewSeen('1.2.0')
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Version',
'1.2.0'
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Status',
"what's new seen"
)
expect(settingStore.set).toHaveBeenCalledWith(
'Comfy.Release.Timestamp',
expect.any(Number)
)
expect(settingStore.setMany).toHaveBeenCalledWith({
'Comfy.Release.Version': '1.2.0',
'Comfy.Release.Status': "what's new seen",
'Comfy.Release.Timestamp': expect.any(Number)
})
})
})

View File

@@ -208,9 +208,11 @@ export const useReleaseStore = defineStore('release', () => {
return
}
await settingStore.set('Comfy.Release.Version', version)
await settingStore.set('Comfy.Release.Status', 'skipped')
await settingStore.set('Comfy.Release.Timestamp', Date.now())
await settingStore.setMany({
'Comfy.Release.Version': version,
'Comfy.Release.Status': 'skipped',
'Comfy.Release.Timestamp': Date.now()
})
}
async function handleShowChangelog(version: string): Promise<void> {
@@ -218,9 +220,11 @@ export const useReleaseStore = defineStore('release', () => {
return
}
await settingStore.set('Comfy.Release.Version', version)
await settingStore.set('Comfy.Release.Status', 'changelog seen')
await settingStore.set('Comfy.Release.Timestamp', Date.now())
await settingStore.setMany({
'Comfy.Release.Version': version,
'Comfy.Release.Status': 'changelog seen',
'Comfy.Release.Timestamp': Date.now()
})
}
async function handleWhatsNewSeen(version: string): Promise<void> {
@@ -228,9 +232,11 @@ export const useReleaseStore = defineStore('release', () => {
return
}
await settingStore.set('Comfy.Release.Version', version)
await settingStore.set('Comfy.Release.Status', "what's new seen")
await settingStore.set('Comfy.Release.Timestamp', Date.now())
await settingStore.setMany({
'Comfy.Release.Version': version,
'Comfy.Release.Status': "what's new seen",
'Comfy.Release.Timestamp': Date.now()
})
}
// Fetch releases from API