1
1
import { produce } from 'immer' ;
2
2
import _ , { values } from 'lodash' ;
3
3
import * as types from '../constants/actionTypes.ts' ;
4
+ import { current } from 'immer' ;
4
5
5
6
export default ( state , action ) =>
6
7
produce ( state , ( draft ) => {
7
8
const { port, currentTab, tabs } = draft ;
8
9
const { hierarchy, snapshots, mode, intervalId, viewIndex, sliderIndex } =
9
10
tabs [ currentTab ] || { } ;
10
11
12
+ // console.log('----consoles before reducer funcs!-----')
13
+ // console.log('state:', state)
14
+ //console.log(tabs[currentTab]);
15
+ //console.log('properties of tabs[currentTab]:', hierarchy, snapshots, mode, intervalId, viewIndex, sliderIndex)
16
+
17
+ //console.log('reducer file!', 'hierarchy:', hierarchy, 'tabs:', tabs)
18
+
11
19
// eslint-disable-next-line max-len
12
20
// function that finds the index in the hierarchy and extracts the name of the equivalent index to add to the post message
13
21
// eslint-disable-next-line consistent-return
@@ -36,6 +44,7 @@ export default (state, action) =>
36
44
switch ( action . type ) {
37
45
// This saves the series user wants to save to chrome local storage
38
46
case types . SAVE : {
47
+ console . log ( 'save action reducer!' , 'payload:' , action . payload )
39
48
const { newSeries, newSeriesName } = action . payload ;
40
49
if ( ! tabs [ currentTab ] . seriesSavedStatus ) {
41
50
tabs [ currentTab ] = { ...tabs [ currentTab ] , seriesSavedStatus : 'inputBoxOpen' } ;
@@ -177,6 +186,9 @@ export default (state, action) =>
177
186
}
178
187
case types . EMPTY : {
179
188
// send msg to background script
189
+ console . log ( '-----clear snapshots reducer----' )
190
+ console . log ( 'state before:' , state . tabs [ currentTab ] )
191
+
180
192
port . postMessage ( { action : 'emptySnap' , tabId : currentTab } ) ;
181
193
tabs [ currentTab ] . sliderIndex = 0 ;
182
194
tabs [ currentTab ] . viewIndex = 0 ;
@@ -201,12 +213,26 @@ export default (state, action) =>
201
213
break ;
202
214
}
203
215
case types . IMPORT : {
216
+ // Log the value of tabs[currentTab].snapshots before the update
217
+ console . log ( '-----import snapshots reducer----' )
218
+ console . log ( 'state before:' , state . tabs [ currentTab ] )
219
+
220
+
204
221
port . postMessage ( {
205
222
action : 'import' ,
206
223
payload : action . payload ,
207
224
tabId : currentTab ,
208
225
} ) ;
226
+
227
+
209
228
tabs [ currentTab ] . snapshots = action . payload ;
229
+
230
+
231
+
232
+ // console.log('New snapshots:', action.payload);
233
+ // console.log('updated tabs[CurrentTab].snapshots:', tabs[currentTab].snapshots)
234
+ //console.log('state after:', state)
235
+
210
236
break ;
211
237
}
212
238
case types . TOGGLE_MODE : {
0 commit comments