@@ -24,20 +24,13 @@ function createTabObj(title) {
24
24
} ;
25
25
}
26
26
27
-
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 ;
37
- this . stateSnapshot = obj ;
38
- this . children = [ ] ;
39
- }
40
- } ;
27
+ class Node {
28
+ constructor ( obj , tabObj ) {
29
+ this . index = tabObj . index += 1 ;
30
+ this . stateSnapshot = obj ;
31
+ this . children = [ ] ;
32
+ }
33
+ } ;
41
34
42
35
function sendToHierarchy ( tabObj , newNode ) {
43
36
if ( ! tabObj . currLocation ) {
@@ -48,6 +41,7 @@ function sendToHierarchy (tabObj, newNode) {
48
41
tabObj . currLocation = newNode ;
49
42
}
50
43
}
44
+
51
45
function changeCurrLocation ( tabObj , rootNode , index ) {
52
46
// check if current node has the index wanted
53
47
if ( rootNode . index === index ) {
@@ -130,15 +124,16 @@ chrome.runtime.onConnect.addListener(port => {
130
124
131
125
// background.js recieves message from contentScript.js
132
126
chrome . runtime . onMessage . addListener ( ( request , sender ) => {
127
+ console . log ( 'received request' , request ) ;
133
128
// IGNORE THE AUTOMATIC MESSAGE SENT BY CHROME WHEN CONTENT SCRIPT IS FIRST LOADED
134
129
if ( request . type === 'SIGN_CONNECT' ) return ;
135
130
const tabTitle = sender . tab . title ;
136
131
const tabId = sender . tab . id ;
137
- const { action } = request ;
132
+ const { action, index } = request ;
138
133
let isReactTimeTravel = false ;
139
134
140
135
// Filter out tabs that don't have reactime
141
- if ( action === 'tabReload' || action === 'recordSnap' ) {
136
+ if ( action === 'tabReload' || action === 'recordSnap' || action === 'jumpToSnap' ) {
142
137
isReactTimeTravel = true ;
143
138
} else return ;
144
139
@@ -150,13 +145,19 @@ chrome.runtime.onMessage.addListener((request, sender) => {
150
145
const { persist } = tabsObj [ tabId ] . mode ;
151
146
152
147
switch ( action ) {
148
+ case 'jumpToSnap' : {
149
+ console . log ( "im triggered" )
150
+ changeCurrLocation ( tabsObj [ tabId ] , tabsObj [ tabId ] . hierarchy , index ) ;
151
+ break ;
152
+ }
153
153
case 'tabReload' : {
154
+ console . log ( "tabreload triggered" )
154
155
tabsObj [ tabId ] . mode . locked = false ;
155
156
tabsObj [ tabId ] . mode . paused = false ;
156
157
// dont remove snapshots if persisting
157
158
if ( ! persist ) {
158
159
tabsObj [ tabId ] . snapshots . splice ( 1 ) ;
159
- // reset children in root node to reset graph
160
+ // reset children in root node to reset graph
160
161
tabsObj [ tabId ] . hierarchy . children = [ ] ;
161
162
// reassigning pointer to the appropriate node to branch off of
162
163
tabsObj [ tabId ] . currLocation = tabsObj [ tabId ] . hierarchy ;
0 commit comments