@@ -8,10 +8,9 @@ const firstSnapshotReceived = {};
8
8
// there will be the same number of objects in here as there are reactime tabs open for each user application being worked on
9
9
const tabsObj = { } ;
10
10
11
- console . log ( " background scripts" ) ;
11
+ console . log ( ' background scripts' ) ;
12
12
13
13
function createTabObj ( title ) {
14
-
15
14
// update tabsObj
16
15
return {
17
16
title,
@@ -62,14 +61,17 @@ function changeCurrLocation(tabObj, rootNode, index) {
62
61
return ;
63
62
// if not, recurse on each one of the children
64
63
}
65
- rootNode . children . forEach ( child => {
66
- changeCurrLocation ( tabObj , child , index ) ;
67
- } ) ;
64
+ // added if (rootNode.children) { <=======
65
+ if ( rootNode . children ) {
66
+ rootNode . children . forEach ( child => {
67
+ changeCurrLocation ( tabObj , child , index ) ;
68
+ } ) ;
69
+ }
68
70
}
69
71
70
-
71
72
// establishing connection with devtools
72
- chrome . runtime . onConnect . addListener ( port => { // port is one end of the connection - an object
73
+ chrome . runtime . onConnect . addListener ( port => {
74
+ // port is one end of the connection - an object
73
75
74
76
// push every port connected to the ports array
75
77
portsArr . push ( port ) ;
@@ -92,8 +94,9 @@ chrome.runtime.onConnect.addListener(port => { // port is one end of the connect
92
94
}
93
95
} ) ;
94
96
95
- // receive snapshot from devtools and send it to contentScript -
96
- port . onMessage . addListener ( msg => { // msg is action denoting a time jump in devtools
97
+ // receive snapshot from devtools and send it to contentScript -
98
+ port . onMessage . addListener ( msg => {
99
+ // msg is action denoting a time jump in devtools
97
100
98
101
// ---------------------------------------------------------------
99
102
// message incoming from devTools should look like this:
@@ -143,7 +146,11 @@ chrome.runtime.onMessage.addListener((request, sender) => {
143
146
let isReactTimeTravel = false ;
144
147
145
148
// Filter out tabs that don't have reactime
146
- if ( action === 'tabReload' || action === 'recordSnap' || action === 'jumpToSnap' ) {
149
+ if (
150
+ action === 'tabReload' ||
151
+ action === 'recordSnap' ||
152
+ action === 'jumpToSnap'
153
+ ) {
147
154
isReactTimeTravel = true ;
148
155
} else return ;
149
156
@@ -175,10 +182,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
175
182
tabsObj [ tabId ] . index = 1 ;
176
183
177
184
// send a message to devtools
178
- portsArr . forEach ( bg => bg . postMessage ( {
179
- action : 'initialConnectSnapshots' ,
180
- payload : tabsObj ,
181
- } ) ) ;
185
+ portsArr . forEach ( bg =>
186
+ bg . postMessage ( {
187
+ action : 'initialConnectSnapshots' ,
188
+ payload : tabsObj ,
189
+ } )
190
+ ) ;
182
191
}
183
192
reloaded [ tabId ] = true ;
184
193
break ;
@@ -191,12 +200,17 @@ chrome.runtime.onMessage.addListener((request, sender) => {
191
200
reloaded [ tabId ] = false ;
192
201
193
202
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
194
- sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload , tabsObj [ tabId ] ) ) ;
203
+ sendToHierarchy (
204
+ tabsObj [ tabId ] ,
205
+ new Node ( request . payload , tabsObj [ tabId ] )
206
+ ) ;
195
207
if ( portsArr . length > 0 ) {
196
- portsArr . forEach ( bg => bg . postMessage ( {
197
- action : 'initialConnectSnapshots' ,
198
- payload : tabsObj ,
199
- } ) ) ;
208
+ portsArr . forEach ( bg =>
209
+ bg . postMessage ( {
210
+ action : 'initialConnectSnapshots' ,
211
+ payload : tabsObj ,
212
+ } )
213
+ ) ;
200
214
}
201
215
break ;
202
216
}
@@ -207,15 +221,20 @@ chrome.runtime.onMessage.addListener((request, sender) => {
207
221
} else {
208
222
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
209
223
//! INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN!!!!
210
- sendToHierarchy ( tabsObj [ tabId ] , new Node ( request . payload , tabsObj [ tabId ] ) ) ;
224
+ sendToHierarchy (
225
+ tabsObj [ tabId ] ,
226
+ new Node ( request . payload , tabsObj [ tabId ] )
227
+ ) ;
211
228
}
212
229
// send message to devtools
213
230
if ( portsArr . length > 0 ) {
214
- portsArr . forEach ( bg => bg . postMessage ( {
215
- action : 'sendSnapshots' ,
216
- payload : tabsObj ,
217
- sourceTab,
218
- } ) ) ;
231
+ portsArr . forEach ( bg =>
232
+ bg . postMessage ( {
233
+ action : 'sendSnapshots' ,
234
+ payload : tabsObj ,
235
+ sourceTab,
236
+ } )
237
+ ) ;
219
238
}
220
239
break ;
221
240
}
@@ -228,10 +247,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
228
247
chrome . tabs . onRemoved . addListener ( tabId => {
229
248
// tell devtools which tab to delete
230
249
if ( portsArr . length > 0 ) {
231
- portsArr . forEach ( bg => bg . postMessage ( {
232
- action : 'deleteTab' ,
233
- payload : tabId ,
234
- } ) ) ;
250
+ portsArr . forEach ( bg =>
251
+ bg . postMessage ( {
252
+ action : 'deleteTab' ,
253
+ payload : tabId ,
254
+ } )
255
+ ) ;
235
256
}
236
257
237
258
// delete the tab from the tabsObj
@@ -253,7 +274,7 @@ chrome.runtime.onInstalled.addListener(() => {
253
274
// when context menu is clicked, listen for the menuItemId,
254
275
// if user clicked on reactime, open the devtools window
255
276
chrome . contextMenus . onClicked . addListener ( ( { menuItemId } ) => {
256
- console . log ( " clicked menu" ) ;
277
+ console . log ( ' clicked menu' ) ;
257
278
const options = {
258
279
type : 'panel' ,
259
280
left : 0 ,
0 commit comments