Skip to content

Commit 3bcdacc

Browse files
committed
Updated save series button
1 parent 4860a8c commit 3bcdacc

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

src/app/components/BarGraph.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @ts-nocheck
2-
import React from 'react';
2+
import React, { useEffect } from 'react';
33
import { BarStack } from '@visx/shape';
44
import { SeriesPoint } from '@visx/shape/lib/types';
55
import { Group } from '@visx/group';
@@ -109,19 +109,19 @@ const BarGraph = (props) => {
109109
data,
110110
};
111111

112-
const animateButton = function (e) {
113-
e.preventDefault;
114-
e.target.classList.add('animate');
115-
e.target.innerHTML = 'Saved!';
116-
setTimeout(function () {
117-
e.target.innerHTML = 'Save Series';
118-
e.target.classList.remove('animate');
119-
}, 1000);
120-
};
121-
const classname = document.getElementsByClassName('save-series-button');
122-
for (let i = 0; i < classname.length; i++) {
123-
classname[i].addEventListener('click', animateButton, false);
124-
}
112+
// use this to animate the save series button. It
113+
useEffect(() => {
114+
const saveButtons = document.getElementsByClassName('save-series-button');
115+
for (let i = 0; i < saveButtons.length; i++) {
116+
if (tabs[currentTab].seriesSavedStatus) {
117+
saveButtons[i].classList.add('animate');
118+
saveButtons[i].innerHTML = 'Saved!';
119+
} else {
120+
saveButtons[i].innerHTML = 'Save Series';
121+
saveButtons[i].classList.remove('animate');
122+
};
123+
};
124+
});
125125
return (
126126
<div className='bargraph-position'>
127127
<button

src/app/containers/MainContainer.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ function MainContainer(): any {
6060
case 'sendSnapshots': {
6161
dispatch(setTab(sourceTab));
6262
// set state with the information received from the background script
63+
console.log('sendSnapshots payload\n', payload); // HFConsoleLog
6364
dispatch(addNewSnapshots(payload));
6465
break;
6566
}

src/app/reducers/mainReducer.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export default (state, action) =>
3838
case types.SAVE: {
3939
const data = JSON.stringify(action.payload);
4040
localStorage.setItem(`${action.payload.currentTab}`, data);
41+
tabs[currentTab] = {...tabs[currentTab], seriesSavedStatus: true};
42+
console.log('seriesSavedStatus set to true from saving series');
4143
break;
4244
}
4345
// Delete case will delete ALL stored series in chrome local storage. To see chrome storage related data
@@ -56,6 +58,7 @@ export default (state, action) =>
5658
...tabs[tab],
5759
};
5860
});
61+
tabs[currentTab] = {...tabs[currentTab], seriesSavedStatus: false}
5962
}
6063
case types.ON_HOVER_EXIT: {
6164
port.postMessage({
@@ -187,6 +190,8 @@ export default (state, action) =>
187190
tabs[currentTab].currParent = 1;
188191
// resets currBranch
189192
tabs[currentTab].currBranch = 0;
193+
// resets series saved status
194+
tabs[currentTab].seriesSavedStatus = false;
190195
break;
191196
}
192197
case types.SET_PORT: {
@@ -265,7 +270,9 @@ export default (state, action) =>
265270
...tabs[tab],
266271
...payload[tab],
267272
sliderIndex: newSnaps.length - 1,
273+
seriesSavedStatus: false,
268274
};
275+
console.log('seriesSavedStatus set to false from new snapshot');
269276
}
270277
});
271278

0 commit comments

Comments
 (0)