Skip to content

Commit 912ae2d

Browse files
committed
fix(helpers): fix deep attribute picking
1 parent 2cff70e commit 912ae2d

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

src/helpers/overlaysDefaultValues.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { MINUTE, SECOND } from '@sogebot/ui-helpers/constants';
22
import { defaultsDeep, pick } from 'lodash';
33

4+
import { flatten, unflatten } from './flatten';
5+
46
import { Overlay } from '~/database/entity/overlay';
57

68
const values = {
@@ -257,13 +259,15 @@ const values = {
257259
} as const;
258260

259261
function setDefaultOpts<T extends keyof typeof values>(opts: any, type: T): Overlay['items'][number]['opts'] {
260-
return pick(
261-
{
262-
...defaultsDeep(opts, values[type]),
263-
typeId: type,
264-
},
265-
Object.keys({ ...values[type], typeId: '' }),
266-
) as any;
262+
const val = {
263+
...defaultsDeep(opts, values[type]),
264+
typeId: type,
265+
};
266+
267+
const expectedKeys = Object.keys(flatten({ ...values[type], typeId: '' }));
268+
// flatten to get proper pick
269+
const picked = pick(flatten(val), expectedKeys);
270+
return unflatten(picked) as Overlay['items'][number]['opts'];
267271
}
268272

269273
function defaultValues(overlay: Overlay) {

0 commit comments

Comments
 (0)