File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { MINUTE , SECOND } from '@sogebot/ui-helpers/constants' ;
22import { defaultsDeep , pick } from 'lodash' ;
33
4+ import { flatten , unflatten } from './flatten' ;
5+
46import { Overlay } from '~/database/entity/overlay' ;
57
68const values = {
@@ -257,13 +259,15 @@ const values = {
257259} as const ;
258260
259261function 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
269273function defaultValues ( overlay : Overlay ) {
You can’t perform that action at this time.
0 commit comments