diff --git a/src/scripts/background.js b/src/scripts/background.js index c6285e5b4..f83fa403a 100644 --- a/src/scripts/background.js +++ b/src/scripts/background.js @@ -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; @@ -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