Skip to content

Commit

Permalink
fix null dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-vorobiov committed Jan 8, 2025
1 parent a869bf7 commit 053fb5b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion evolve_analytics.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Evolve Analytics
// @namespace http://tampermonkey.net/
// @version 0.10.4
// @version 0.10.5
// @description Track and see detailed information about your runs
// @author Sneed
// @match https://pmotschmann.github.io/Evolve/
Expand Down
10 changes: 7 additions & 3 deletions src/ui/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ function* timestamps(plotPoints: PlotPoint[], key: "day" | "segment") {
});
}

function* statsMarks(runs: HistoryEntry[], bestRun: HistoryEntry) {
function* statsMarks(runs: HistoryEntry[], bestRun: HistoryEntry | undefined) {
if (bestRun === undefined) {
return;
}

const bestIdx = runs.indexOf(bestRun);
yield Plot.axisX([bestIdx], {
tickFormat: () => "PB",
Expand Down Expand Up @@ -295,7 +299,7 @@ export function makeGraph(history: HistoryManager, view: View, currentRun: Lates
marks.push(...lollipopMarks(plotPoints, false, filteredRuns.length));
marks.push(...timestamps(plotPoints, "day"));
marks.push(...rectPointerMarks(plotPoints, filteredRuns, "dayDiff", "day"));
marks.push(...statsMarks(filteredRuns, bestRun!));
marks.push(...statsMarks(filteredRuns, bestRun));
break;

case "duration":
Expand All @@ -318,7 +322,7 @@ export function makeGraph(history: HistoryManager, view: View, currentRun: Lates

marks.push(...lineMarks(plotPoints, filteredRuns, "day", view.smoothness));
marks.push(...timestamps(plotPoints, "day"));
marks.push(...statsMarks(filteredRuns, bestRun!));
marks.push(...statsMarks(filteredRuns, bestRun));
break;

case "duration":
Expand Down

0 comments on commit 053fb5b

Please sign in to comment.