@@ -3,12 +3,8 @@ import { MappingExt, MappingsExt } from '@sofie-automation/corelib/dist/dataMode
33import { IBlueprintConfig , ISourceLayer , SchemaFormUIField } from '@sofie-automation/blueprints-integration'
44import { groupByToMapFunc , literal } from '@sofie-automation/corelib/dist/lib'
55import { useTranslation } from 'react-i18next'
6- import {
7- applyAndValidateOverrides ,
8- ObjectWithOverrides ,
9- SomeObjectOverrideOp ,
10- } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
11- import { useOverrideOpHelper , WrappedOverridableItemNormal } from '../util/OverrideOpHelper.js'
6+ import { ObjectWithOverrides , SomeObjectOverrideOp } from '@sofie-automation/corelib/dist/settings/objectWithOverrides'
7+ import { useOverrideOpHelperForSimpleObject } from '../util/OverrideOpHelper.js'
128import { JSONSchema } from '@sofie-automation/shared-lib/dist/lib/JSONSchemaTypes'
139import deepmerge from 'deepmerge'
1410import { SchemaFormSofieEnumDefinition , translateStringIfHasNamespaces } from '../../../lib/forms/schemaFormUtil.js'
@@ -87,41 +83,25 @@ export function BlueprintConfigSchemaSettings({
8783 }
8884 } , [ layerMappings , sourceLayers ] )
8985
90- const [ wrappedItem , wrappedConfigObject ] = useMemo ( ( ) => {
86+ const combinedObject = useMemo < ObjectWithOverrides < IBlueprintConfig > > ( ( ) => {
87+ // TODO - replace based around a custom implementation of OverrideOpHelperForItemContents?
88+
9189 const combinedDefaults : IBlueprintConfig = alternateConfig
9290 ? deepmerge < IBlueprintConfig > ( alternateConfig , rawConfigObject . defaults , {
9391 arrayMerge : ( _destinationArray , sourceArray , _options ) => sourceArray ,
9492 } )
9593 : rawConfigObject . defaults
9694
97- const prefixedOps = rawConfigObject . overrides . map ( ( op ) => ( {
98- ...op ,
99- // TODO: can we avoid doing this hack?
100- path : `0.${ op . path } ` ,
101- } ) )
102-
103- const computedValue = applyAndValidateOverrides ( {
95+ return {
10496 defaults : combinedDefaults ,
10597 overrides : rawConfigObject . overrides ,
106- } ) . obj
107-
108- const wrappedItem = literal < WrappedOverridableItemNormal < IBlueprintConfig > > ( {
109- type : 'normal' ,
110- id : '0' ,
111- computed : computedValue ,
112- defaults : combinedDefaults ,
113- overrideOps : prefixedOps ,
114- } )
115-
116- const wrappedConfigObject : ObjectWithOverrides < IBlueprintConfig > = {
117- defaults : combinedDefaults ,
118- overrides : prefixedOps ,
11998 }
99+ } , [ alternateConfig , rawConfigObject ] )
120100
121- return [ wrappedItem , wrappedConfigObject ]
122- } , [ rawConfigObject ] )
123-
124- const overrideHelper = useOverrideOpHelper ( saveOverridesStrippingPrefix , wrappedConfigObject ) // TODO - replace based around a custom implementation of OverrideOpHelperForItemContents?
101+ const { overrideHelper , wrappedItem } = useOverrideOpHelperForSimpleObject (
102+ saveOverridesStrippingPrefix ,
103+ combinedObject
104+ )
125105
126106 const groupedSchema = useMemo ( ( ) => {
127107 if ( schema ?. type === 'object' && schema . properties ) {
0 commit comments