Skip to content

Commit

Permalink
fix: Fix errors on workdayEnd when $curEntry is null
Browse files Browse the repository at this point in the history
Add a defensive check. This seems to have come about because of async functions.
  • Loading branch information
tcrammond committed Mar 21, 2019
1 parent b5c94bf commit 8951ef4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/scripts/background.js
Expand Up @@ -1435,6 +1435,10 @@ window.TogglButton = {
},

checkWorkDayEnd: async function () {
if (!TogglButton.$curEntry) {
return;
}

const stopAtDayEnd = await db.get('stopAtDayEnd');
const hasWorkdayEnded = await TogglButton.workdayEnded();
if (
Expand Down Expand Up @@ -1469,6 +1473,9 @@ window.TogglButton = {
},

workdayEnded: async function () {
if (!TogglButton.$curEntry) {
return false;
}
const startedTime = new Date(TogglButton.$curEntry.start);
const now = new Date();
const endTime = new Date();
Expand Down

0 comments on commit 8951ef4

Please sign in to comment.