@@ -11,6 +11,7 @@ function createTabObj(title) {
11
11
title,
12
12
// snapshots is an array of ALL state snapshots for the reactime tab working on a specific user application
13
13
snapshots : [ ] ,
14
+ index : 0 ,
14
15
//* this is our pointer so we know what the current state the user is checking (this accounts for time travel aka when user clicks jump on the UI)
15
16
currLocation : null ,
16
17
//* inserting a new property to build out our hierarchy dataset for d3
@@ -23,19 +24,20 @@ function createTabObj(title) {
23
24
} ;
24
25
}
25
26
26
- const makeNewNode = ( ) => {
27
- let num = 0 ;
28
27
29
- return class Node {
30
- constructor ( obj ) {
31
- this . index = num += 1 ;
28
+ // function resetIndex(num) {
29
+ // return num = 0;
30
+ // }
31
+
32
+ // let num = 0;
33
+
34
+ class Node {
35
+ constructor ( obj , tabObj ) {
36
+ this . index = tabObj . index += 1 ;
32
37
this . stateSnapshot = obj ;
33
38
this . children = [ ] ;
34
39
}
35
40
} ;
36
- } ;
37
-
38
- const Node = makeNewNode ( ) ;
39
41
40
42
function sendToHierarchy ( tabObj , newNode ) {
41
43
if ( ! tabObj . currLocation ) {
@@ -72,7 +74,7 @@ chrome.runtime.onConnect.addListener(port => {
72
74
if ( Object . keys ( tabsObj ) . length > 0 ) {
73
75
port . postMessage ( {
74
76
action : 'initialConnectSnapshots' ,
75
- payload : { ...tabsObj , msg : 'connection to devgools made' } ,
77
+ payload : { ...tabsObj , msg : 'connection to devgools made' } ,
76
78
} ) ;
77
79
}
78
80
@@ -103,6 +105,12 @@ chrome.runtime.onConnect.addListener(port => {
103
105
return ;
104
106
case 'emptySnap' :
105
107
tabsObj [ tabId ] . snapshots . splice ( 1 ) ;
108
+ // reset children in root node to reset graph
109
+ tabsObj [ tabId ] . hierarchy . children = [ ] ;
110
+ // reassigning pointer to the appropriate node to branch off of
111
+ tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ;
112
+ // reset index
113
+ tabsObj [ tabId ] . index = 1 ;
106
114
return ;
107
115
case 'setLock' :
108
116
tabsObj [ tabId ] . mode . locked = payload ;
@@ -148,6 +156,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
148
156
// dont remove snapshots if persisting
149
157
if ( ! persist ) {
150
158
tabsObj [ tabId ] . snapshots . splice ( 1 ) ;
159
+ // reset children in root node to reset graph
160
+ tabsObj [ tabId ] . hierarchy . children = [ ] ;
161
+ // reassigning pointer to the appropriate node to branch off of
162
+ tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ;
163
+ // reset index
164
+ tabsObj [ tabId ] . index = 1 ;
151
165
152
166
// send a message to devtools
153
167
portsArr . forEach ( bg => bg . postMessage ( {
@@ -170,7 +184,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
170
184
reloaded [ tabId ] = false ;
171
185
172
186
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
173
- sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload ) ) ;
187
+ sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload , tabsObj [ tabId ] ) ) ;
174
188
if ( portsArr . length > 0 ) {
175
189
portsArr . forEach ( bg => bg . postMessage ( {
176
190
action : 'initialConnectSnapshots' ,
@@ -186,7 +200,7 @@ chrome.runtime.onMessage.addListener((request, sender) => {
186
200
} else {
187
201
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
188
202
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
189
- sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload ) ) ;
203
+ sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload , tabsObj [ tabId ] ) ) ;
190
204
}
191
205
// send message to devtools
192
206
if ( portsArr . length > 0 ) {
0 commit comments