@@ -17,9 +17,14 @@ function createTabObj(title) {
17
17
title,
18
18
// snapshots is an array of ALL state snapshots for the reactime tab working on a specific user application
19
19
snapshots : [ ] ,
20
- index : 0 ,
20
+ // gabi and nate :: index here is the tab index that show total amount of state changes
21
+ index : 0 ,
21
22
//* 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)
22
23
currLocation : null ,
24
+ // gabi and nate :: point the node that will generate the next child set by newest node or jump
25
+ currParent : 0 ,
26
+ // gabi and nate :: points to the current branch
27
+ currBranch : 0 ,
23
28
//* inserting a new property to build out our hierarchy dataset for d3
24
29
hierarchy : null ,
25
30
mode : {
@@ -35,7 +40,12 @@ class Node {
35
40
// eslint-disable-next-line no-param-reassign
36
41
// eslint-disable-next-line no-multi-assign
37
42
// eslint-disable-next-line no-plusplus
43
+ // gabi and nate :: continue the order of number of total state changes
38
44
this . index = tabObj . index ++ ;
45
+ // gabi and nate :: continue the order of number of states changed from that parent
46
+ this . name = tabObj . currParent += 1 ;
47
+ // gabi and nate :: mark from what branch this node is originated
48
+ this . branch = tabObj . currBranch ;
39
49
this . stateSnapshot = obj ;
40
50
this . children = [ ] ;
41
51
console . log ( 'created node in background.js constructor' ) ;
@@ -48,14 +58,24 @@ function sendToHierarchy(tabObj, newNode) {
48
58
tabObj . hierarchy = newNode ;
49
59
} else {
50
60
tabObj . currLocation . children . push ( newNode ) ;
61
+ // gabi and nate :: if the node's children's array is empty
62
+ if ( tabObj . currLocation . children . length > 1 ) {
63
+ // gabi and nate :: increment the value of the nodes branch by 1
64
+ newNode . branch += 1
65
+ // gabi and nate :: reassign value of current branch to be the length of the children array less one
66
+ tabObj . currBranch = tabObj . currLocation . children . length - 1 ;
67
+ }
51
68
tabObj . currLocation = newNode ;
52
69
}
53
70
}
54
71
55
72
function changeCurrLocation ( tabObj , rootNode , index ) {
73
+ // gabi and nate :: index comes from the app's main reducer to locate the right current location on tabObj
56
74
// check if current node has the index wanted
57
- if ( rootNode . index === index ) {
75
+ if ( rootNode . index === index ) {
58
76
tabObj . currLocation = rootNode ;
77
+ // gabi and nate :: index of current location from where the next node will be a child
78
+ tabObj . currParent = index ;
59
79
return ;
60
80
}
61
81
// base case if no children
@@ -165,6 +185,9 @@ chrome.runtime.onMessage.addListener((request, sender) => {
165
185
166
186
switch ( action ) {
167
187
case 'jumpToSnap' : {
188
+ // console.log('this tabsObj[tabId] sent to changeCurrLocation', tabsObj[tabId])
189
+ // console.log('this tabsObj[tabId].hierarchy sent to changeCurrLocation', tabsObj[tabId].hierarchy)
190
+ // console.log('this index sent to changeCurrLocation', index)
168
191
changeCurrLocation ( tabsObj [ tabId ] , tabsObj [ tabId ] . hierarchy , index ) ;
169
192
break ;
170
193
}
0 commit comments