@@ -212,61 +212,41 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
212
212
const providerComponent = state . components [ componentProviderId - 1 ] ;
213
213
const providerStates = providerComponent . stateProps ;
214
214
const newInput = providerStates [ statePropsId - 1 ] . value ;
215
+ let newContextObj = { ...currentComponent . useContext } ;
215
216
216
- // states providerComponent
217
- // adding new state into provideComponent
218
- // currComponent = canvas focus component
219
- // currComponent = state.components[componentProviderId - 1]; {1 : {Set, compLink, compText}}
220
- // Our set holds the state row ids of that component
221
-
222
-
223
- // console.log("state-components", JSON.parse(JSON.stringify(state.components)));
224
- // console.log("current-component", JSON.parse(JSON.stringify(currentComponent)));
217
+ if ( ! newContextObj ) {
218
+ newContextObj = { } ;
219
+ }
225
220
226
- if ( attributeName === 'compText' ) {
227
- let newContextObj = { ...currentComponent . useContext } ;
228
- if ( ! newContextObj ) {
229
- newContextObj = { } ;
230
- }
221
+ if ( ! newContextObj [ componentProviderId ] ) {
222
+ newContextObj [ componentProviderId ] = { statesFromProvider : new Set ( ) } ;
223
+ }
231
224
232
- if ( ! newContextObj [ componentProviderId ] ) {
233
- newContextObj [ componentProviderId ] = { statesFromProvider : new Set ( ) } ;
234
- }
225
+ newContextObj [ componentProviderId ] . statesFromProvider . add ( statePropsId ) ;
235
226
227
+ if ( attributeName === 'compText' ) {
236
228
newContextObj [ componentProviderId ] . compText = statePropsId ;
237
- newContextObj [ componentProviderId ] . statesFromProvider . add ( statePropsId ) ;
229
+
238
230
setCompText ( newInput ) ;
239
- // setUseContextObj(newContextObj);
240
-
241
231
dispatch ( {
242
232
type : 'UPDATE USE CONTEXT' ,
243
233
payload : { useContextObj : newContextObj }
244
- } )
234
+ } ) ;
235
+ // setUseContextObj(newContextObj);
245
236
}
237
+
246
238
if ( attributeName === 'compLink' ) {
247
- const newContextObj = useContextObj ;
248
- if ( ! newContextObj [ componentProviderId ] ) {
249
- newContextObj [ componentProviderId ] = { statesFromProvider : new Set ( ) } ;
250
- }
251
- newContextObj [ componentProviderId ] . compLink = statePropsId ;
252
- newContextObj [ componentProviderId ] . statesFromProvider . add ( statePropsId ) ;
253
-
239
+ newContextObj [ componentProviderId ] . compLink = statePropsId ;
240
+
254
241
setCompLink ( newInput ) ;
255
- setUseContextObj ( newContextObj ) ;
242
+ dispatch ( {
243
+ type : 'UPDATE USE CONTEXT' ,
244
+ payload : { useContextObj : newContextObj }
245
+ } ) ;
246
+ // setUseContextObj(newContextObj);
256
247
}
257
-
258
-
259
- // TODO: set something to signify that state was used
260
- // so it can be handled in generateCode
261
-
262
- // update use context object
263
-
264
248
}
265
249
266
- // useEffect(() => {
267
- // console.log(useContextObj);
268
- // }, [useContextObj]);
269
-
270
250
// dispatch to 'UPDATE CSS' called when save button is clicked,
271
251
// passing in style object constructed from all changed input values
272
252
const handleSave = ( ) : Object => {
0 commit comments