Skip to content

Commit

Permalink
Fix the HistoryChart fake data when demo=true and fakeData is being u…
Browse files Browse the repository at this point in the history
…sed. It gets more and more stale by the day. So we need to compensate for that.
  • Loading branch information
chriscareycode committed Dec 13, 2021
1 parent 501fe02 commit dbb5034
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/alerts/AlertSection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,15 @@ const AlertSection = () => {
// If we are in demo mode then let's modify the latest timestamps
if (useFakeSampleData) {
//console.log('myAlertlist', myAlertlist);
myAlertlist[0].timestamp = new Date().getTime();
myAlertlist[1].timestamp = new Date().getTime() - 5000;
//myAlertlist[0].timestamp = new Date().getTime();
//myAlertlist[1].timestamp = new Date().getTime() - 5000;

// Find out how far in the past the newest alert data item is
const howMuchToScoochBy = new Date().getTime() - myAlertlist[0].timestamp;

// Loop through every item and scooch it forward just the right amount
myAlertlist.forEach(a => a.timestamp += howMuchToScoochBy);

}

// We check this since the ajax could take a while to respond and the page may have unmounted
Expand Down

0 comments on commit dbb5034

Please sign in to comment.