fix: admin/accounts: adding a group didn't trigger saving
Massimo Melina committed
Dec 14, 2024 at 12:39 UTC
bd095c161ced3eb5b64d04a1c7cc1f1fa75b6476
1 file changed
+4
-1
src/config.ts
+4
-1
@@ -9,6 +9,9 @@ import { statSync } from 'fs'
9
import { join, resolve } from 'path'
10
import events from './events'
11
import { copyFile, stat } from 'fs/promises'
12
+import produce, { setAutoFreeze } from 'immer'
13
+
14
+setAutoFreeze(false) // we still want to mess with objects later (eg: account.belongs)
15
16
// keep definition of config properties
17
const configProps: Record<string, { defaultValue?: unknown }> = {}
@@ -74,7 +77,7 @@ export function defineConfig<T, CT=unknown>(k: string, defaultValue: T, compiler
77
},
78
set(v: T | Updater) {
79
if (typeof v === 'function')
77
- this.set((v as Updater)(this.get()))
80
+ this.set(produce(this.get(), v as Updater))
81
else
82
setConfig1(k, v)
83
},