Skip to content

Commit

Permalink
chore: Ensure tid/pid values are null when empty to workaround v8/v9 …
Browse files Browse the repository at this point in the history
…differences
  • Loading branch information
tcrammond authored and shantanuraj committed Apr 8, 2019
1 parent 026a8d6 commit ef68da6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ window.TogglButton = {
localStorage.setItem('projects', JSON.stringify(projectMap));
localStorage.setItem('clients', JSON.stringify(clientMap));
TogglButton.$user = resp.data;
TogglButton.$user.time_entries = TogglButton.$user.time_entries.map((te) => {
// Ensure empty values from v8 become null.
return {
...te,
pid: te.pid || null,
tid: te.tid || null
};
});
TogglButton.$user.projectMap = projectMap;
TogglButton.$user.clientMap = clientMap;
TogglButton.$user.clientNameMap = clientNameMap;
Expand Down Expand Up @@ -395,6 +403,11 @@ window.TogglButton = {
return;
}

if (TogglButton.$latestStoppedEntry) {
TogglButton.$latestStoppedEntry.pid = TogglButton.$latestStoppedEntry.pid || TogglButton.$latestStoppedEntry.project_id || null;
TogglButton.$latestStoppedEntry.tid = TogglButton.$latestStoppedEntry.tid || TogglButton.$latestStoppedEntry.task_id || null;
}

if (
!TogglButton.$user.time_entries ||
!Object.keys(TogglButton.$user.time_entries).length
Expand Down

0 comments on commit ef68da6

Please sign in to comment.