@@ -627,9 +627,11 @@ const reducer = (state: State, action: Action) => {
627
627
//the children array of state.components[0] will equal the last element of the past array
628
628
state . components [ 0 ] . children = state . past [ state . past . length - 1 ] ;
629
629
//the last element of past array gets pushed into future;
630
- // state.future.push(state.past[state.past.length - 1]);
630
+ state . future . push ( state . past . pop ( ) ) ;
631
+ // state.past[state.past.length - 1]);
631
632
//pop the last element off the past array
632
- state . past . pop ( ) ;
633
+ // state.past.pop();
634
+ console . log ( 'state in UNDO' , state ) ;
633
635
//generate code for the Code Preview
634
636
state . components . forEach ( ( el , i ) => {
635
637
el . code = generateCode (
@@ -646,15 +648,15 @@ const reducer = (state: State, action: Action) => {
646
648
}
647
649
case 'REDO' : {
648
650
//nothing left to undo
649
- if ( state . past . length === 0 ) return { ...state } ;
651
+ // if (state.past.length === 0) return {...state};
650
652
//nothing left to redo
651
- else if ( state . future . length === 0 ) return { ...state } ;
653
+ if ( state . future . length === 0 ) return { ...state } ;
652
654
//the children array of state.components[0] will equal the last element of the future array
653
655
state . components [ 0 ] . children = state . future [ state . future . length - 1 ] ;
654
656
//the last element of the future array gets pushed into the past array
655
- state . past . push ( state . future [ state . future . length - 1 ] )
657
+ state . past . push ( state . future . pop ( ) ) ;
656
658
//the last element of the future array gets popped off
657
- state . future . pop ( ) ;
659
+ console . log ( 'state in REDO' , state ) ;
658
660
//generate code for the Code Preview
659
661
state . components . forEach ( ( el , i ) => {
660
662
el . code = generateCode (
@@ -664,11 +666,11 @@ const reducer = (state: State, action: Action) => {
664
666
state . projectType ,
665
667
state . HTMLTypes
666
668
) ;
667
- } ) ;
668
- return {
669
- ...state
670
- } ;
671
- }
669
+ } ) ;
670
+ return {
671
+ ...state
672
+ } ;
673
+ }
672
674
673
675
default :
674
676
return state ;
0 commit comments