@@ -8,10 +8,9 @@ const firstSnapshotReceived = {};
88// there will be the same number of objects in here as there are reactime tabs open for each user application being worked on
99const tabsObj = { } ;
1010
11- console . log ( " background scripts" ) ;
11+ console . log ( ' background scripts' ) ;
1212
1313function createTabObj ( title ) {
14-
1514 // update tabsObj
1615 return {
1716 title,
@@ -62,14 +61,17 @@ function changeCurrLocation(tabObj, rootNode, index) {
6261 return ;
6362 // if not, recurse on each one of the children
6463 }
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+ }
6870}
6971
70-
7172// 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
7375
7476 // push every port connected to the ports array
7577 portsArr . push ( port ) ;
@@ -92,8 +94,9 @@ chrome.runtime.onConnect.addListener(port => { // port is one end of the connect
9294 }
9395 } ) ;
9496
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
97100
98101 // ---------------------------------------------------------------
99102 // message incoming from devTools should look like this:
@@ -143,7 +146,11 @@ chrome.runtime.onMessage.addListener((request, sender) => {
143146 let isReactTimeTravel = false ;
144147
145148 // 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+ ) {
147154 isReactTimeTravel = true ;
148155 } else return ;
149156
@@ -175,10 +182,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
175182 tabsObj [ tabId ] . index = 1 ;
176183
177184 // 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+ ) ;
182191 }
183192 reloaded [ tabId ] = true ;
184193 break ;
@@ -191,12 +200,17 @@ chrome.runtime.onMessage.addListener((request, sender) => {
191200 reloaded [ tabId ] = false ;
192201
193202 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+ ) ;
195207 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+ ) ;
200214 }
201215 break ;
202216 }
@@ -207,15 +221,20 @@ chrome.runtime.onMessage.addListener((request, sender) => {
207221 } else {
208222 tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
209223 //! 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+ ) ;
211228 }
212229 // send message to devtools
213230 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+ ) ;
219238 }
220239 break ;
221240 }
@@ -228,10 +247,12 @@ chrome.runtime.onMessage.addListener((request, sender) => {
228247chrome . tabs . onRemoved . addListener ( tabId => {
229248 // tell devtools which tab to delete
230249 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+ ) ;
235256 }
236257
237258 // delete the tab from the tabsObj
@@ -253,7 +274,7 @@ chrome.runtime.onInstalled.addListener(() => {
253274// when context menu is clicked, listen for the menuItemId,
254275// if user clicked on reactime, open the devtools window
255276chrome . contextMenus . onClicked . addListener ( ( { menuItemId } ) => {
256- console . log ( " clicked menu" ) ;
277+ console . log ( ' clicked menu' ) ;
257278 const options = {
258279 type : 'panel' ,
259280 left : 0 ,
0 commit comments