@@ -185,21 +185,28 @@ export default (state, action) =>
185
185
break ;
186
186
}
187
187
case types . EMPTY : {
188
- // send msg to background script
189
188
console . log ( '-----clear snapshots reducer----' )
190
189
console . log ( 'state before:' , state . tabs [ currentTab ] )
191
190
192
- port . postMessage ( { action : 'emptySnap' , tabId : currentTab } ) ;
191
+ // send msg to background script
192
+ port . postMessage ( { action : 'emptySnap' , tabId : currentTab } ) ; //communicate with background.js
193
+
194
+ // properties associated with timetravel + seek bar
193
195
tabs [ currentTab ] . sliderIndex = 0 ;
194
196
tabs [ currentTab ] . viewIndex = 0 ;
195
197
tabs [ currentTab ] . playing = false ;
196
- const lastSnapshot = tabs [ currentTab ] . snapshots [ tabs [ currentTab ] . snapshots . length - 1 ] ;
198
+
199
+ const lastSnapshot = tabs [ currentTab ] . snapshots [ tabs [ currentTab ] . snapshots . length - 1 ] ; // first snapshot?
200
+
197
201
// resets hierarchy to page last state recorded
198
202
tabs [ currentTab ] . hierarchy . stateSnapshot = { ...lastSnapshot } ;
203
+
199
204
// resets hierarchy
200
205
tabs [ currentTab ] . hierarchy . children = [ ] ;
206
+
201
207
// resets snapshots to page last state recorded
202
208
tabs [ currentTab ] . snapshots = [ lastSnapshot ] ;
209
+
203
210
// resets currLocation to page last state recorded
204
211
tabs [ currentTab ] . currLocation = tabs [ currentTab ] . hierarchy ;
205
212
tabs [ currentTab ] . index = 1 ;
@@ -216,16 +223,40 @@ export default (state, action) =>
216
223
// Log the value of tabs[currentTab].snapshots before the update
217
224
console . log ( '-----import snapshots reducer----' )
218
225
console . log ( 'state before:' , state . tabs [ currentTab ] )
219
-
226
+ console . log ( 'action payload:' , action . payload )
220
227
221
228
port . postMessage ( {
222
229
action : 'import' ,
223
- payload : action . payload ,
230
+ payload : action . payload , //.snapshots,
224
231
tabId : currentTab ,
225
232
} ) ;
233
+
234
+ //============
235
+ const savedSnapshot = action . payload ;
236
+
237
+ tabs [ currentTab ] . sliderIndex = savedSnapshot . sliderIndex ;
238
+ tabs [ currentTab ] . viewIndex = savedSnapshot . viewIndex ;
239
+ tabs [ currentTab ] . playing = false ;
240
+
241
+ // resets hierarchy to page last state recorded
242
+ tabs [ currentTab ] . hierarchy . stateSnapshot = savedSnapshot . hierarchy . stateSnapshot ;
243
+
244
+ // resets hierarchy
245
+ tabs [ currentTab ] . hierarchy . children = savedSnapshot . hierarchy . children ;
246
+
247
+ // resets snapshots to page last state recorded
248
+ tabs [ currentTab ] . snapshots = savedSnapshot . snapshots ;
249
+
250
+ // resets currLocation to page last state recorded
251
+ tabs [ currentTab ] . currLocation = tabs [ currentTab ] . hierarchy ;
252
+ tabs [ currentTab ] . index = savedSnapshot . index ;
253
+ tabs [ currentTab ] . currParent = savedSnapshot . currParent ;
254
+ tabs [ currentTab ] . currBranch = savedSnapshot . Branch ;
255
+ tabs [ currentTab ] . seriesSavedStatus = false ;
256
+
226
257
227
-
228
- tabs [ currentTab ] . snapshots = action . payload ;
258
+ //============
259
+ // tabs[currentTab].snapshots = action.payload.snapshots ;
229
260
230
261
231
262
0 commit comments