+
{naruonAvailable ? t("No observed calendar events are available.") : failClosedCopy} diff --git a/frontend/src/focusedGraphSelection.test.ts b/frontend/src/focusedGraphSelection.test.ts new file mode 100644 index 000000000..f8522cf67 --- /dev/null +++ b/frontend/src/focusedGraphSelection.test.ts @@ -0,0 +1,9 @@ +import { describe, expect, it } from "vitest"; +import { focusedGraphMustReset } from "./focusedGraphSelection"; + +describe("focusedGraphMustReset", () => { + it("retains a loaded graph when the already-open post is selected again", () => { + expect(focusedGraphMustReset("post-1", "post-1")).toBe(false); + expect(focusedGraphMustReset("post-1", "post-2")).toBe(true); + }); +}); diff --git a/frontend/src/focusedGraphSelection.ts b/frontend/src/focusedGraphSelection.ts new file mode 100644 index 000000000..286e4eb47 --- /dev/null +++ b/frontend/src/focusedGraphSelection.ts @@ -0,0 +1,4 @@ +/** Return whether selecting a post requires discarding the currently focused graph. */ +export function focusedGraphMustReset(currentPostId: string | null, nextPostId: string): boolean { + return currentPostId !== nextPostId; +}