@@ -41,7 +41,7 @@ import {createAction, Action} from 'redux-actions';
41
41
import { addHttpHeaders } from '../actions' ;
42
42
import { notifyObservers , updateProps } from './index' ;
43
43
import { CallbackJobPayload } from '../reducers/callbackJobs' ;
44
- import { handlePatch , isPatch , parsePatchProps } from './patch' ;
44
+ import { parsePatchProps } from './patch' ;
45
45
import { computePaths , getPath } from './paths' ;
46
46
47
47
import { requestDependencies } from './requestDependencies' ;
@@ -818,12 +818,23 @@ export function executeCallback(
818
818
819
819
if ( clientside_function ) {
820
820
try {
821
- const data = await handleClientside (
821
+ let data = await handleClientside (
822
822
dispatch ,
823
823
clientside_function ,
824
824
config ,
825
825
payload
826
826
) ;
827
+ // Patch methodology: always run through parsePatchProps for each output
828
+ const currentLayout = getState ( ) . layout ;
829
+ flatten ( outputs ) . forEach ( ( out : any ) => {
830
+ const propName = cleanOutputProp ( out . property ) ;
831
+ const outputPath = getPath ( paths , out . id ) ;
832
+ const dataPath = [ stringifyId ( out . id ) , propName ] ;
833
+ const outputValue = path ( dataPath , data ) ;
834
+ const oldProps = path ( outputPath . concat ( [ 'props' ] ) , currentLayout ) || { } ;
835
+ const newProps = parsePatchProps ( { [ propName ] : outputValue } , oldProps ) ;
836
+ data = assocPath ( dataPath , newProps [ propName ] , data ) ;
837
+ } ) ;
827
838
return { data, payload} ;
828
839
} catch ( error : any ) {
829
840
return { error, payload} ;
@@ -882,26 +893,16 @@ export function executeCallback(
882
893
dispatch ( addHttpHeaders ( newHeaders ) ) ;
883
894
}
884
895
// Layout may have changed.
896
+ // DRY: Always run through parsePatchProps for each output
885
897
const currentLayout = getState ( ) . layout ;
886
898
flatten ( outputs ) . forEach ( ( out : any ) => {
887
899
const propName = cleanOutputProp ( out . property ) ;
888
900
const outputPath = getPath ( paths , out . id ) ;
889
- const previousValue = path (
890
- outputPath . concat ( [ 'props' , propName ] ) ,
891
- currentLayout
892
- ) ;
893
901
const dataPath = [ stringifyId ( out . id ) , propName ] ;
894
902
const outputValue = path ( dataPath , data ) ;
895
- if ( isPatch ( outputValue ) ) {
896
- if ( previousValue === undefined ) {
897
- throw new Error ( 'Cannot patch undefined' ) ;
898
- }
899
- data = assocPath (
900
- dataPath ,
901
- handlePatch ( previousValue , outputValue ) ,
902
- data
903
- ) ;
904
- }
903
+ const oldProps = path ( outputPath . concat ( [ 'props' ] ) , currentLayout ) || { } ;
904
+ const newProps = parsePatchProps ( { [ propName ] : outputValue } , oldProps ) ;
905
+ data = assocPath ( dataPath , newProps [ propName ] , data ) ;
905
906
} ) ;
906
907
907
908
if ( dynamic_creator ) {
0 commit comments