@@ -22,20 +22,46 @@ function Diff({ snapshot, show }) {
2222 previous = snapshots [ sliderIndex - 1 ] ;
2323 // console.log('previous with sliderIndex - 1: ', previous)
2424 }
25- // Nate:: diff function returns a comparaison of two objects, one has an updated change
26- const delta = diff ( previous , snapshot ) ; // initilly an array with one object, on state change becomes an object
27- // console.log('delta: ', delta);
28- // returns html in string
29- const html = formatters . html . format ( delta , previous ) ;
30- // console.log('html -->', html)
31- if ( show ) {
32- // console.log('showing unchanged values', formatters.html.showUnchanged() );
33- formatters . html . showUnchanged ( ) ;
34- } else {
35- // console.log('hiding unchanged values', formatters.html.hideUnchanged() );
36- formatters . html . hideUnchanged ( ) ;
25+
26+ // gabi :: cleanning preview from stateless data
27+ const statelessCleanning = obj => {
28+ const newObj = { ...obj } ;
29+ if ( newObj . name === 'nameless' ) {
30+ delete newObj . name ;
31+ }
32+ if ( newObj . componentData ) {
33+ delete newObj . componentData ;
34+ }
35+ if ( newObj . state === 'stateless' ) {
36+ delete newObj . state ;
37+ }
38+ if ( newObj . stateSnaphot ) {
39+ newObj . stateSnaphot = statelessCleanning ( obj . stateSnaphot ) ;
40+ }
41+ if ( newObj . children ) {
42+ newObj . children = [ ] ;
43+ if ( obj . children . length > 0 ) {
44+ obj . children . forEach ( element => {
45+ if ( element . state !== 'stateless' || element . children . length > 0 ) {
46+ const clean = statelessCleanning ( element ) ;
47+ newObj . children . push ( clean ) ;
48+ }
49+ } ) ;
50+ }
51+ }
52+ return newObj ;
3753 } ;
38-
54+ // gabi :: just display stateful data
55+ const previousDisplay = statelessCleanning ( previous ) ;
56+ // Nate:: diff function returns a comparison of two objects, one has an updated change
57+ // gabi :: just display stateful data
58+ const delta = diff ( previousDisplay , snapshot ) ;
59+ // returns html in string
60+ // gabi :: just display stateful data
61+ const html = formatters . html . format ( delta , previousDisplay ) ;
62+ if ( show ) formatters . html . showUnchanged ( ) ;
63+ else formatters . html . hideUnchanged ( ) ;
64+
3965 if ( previous === undefined || delta === undefined ) {
4066 return < div className = 'noState' > No state change detected. Trigger an event to change state </ div > ;
4167 }
0 commit comments