Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix(web): show hours in the share page's chapter list too
Paddy45796a08de3c
diff --git a/apps/web/__tests__/unit/summary-chapters.test.ts b/apps/web/__tests__/unit/summary-chapters.test.tsindex 26f7e4f05..2450941b2 100644--- a/apps/web/__tests__/unit/summary-chapters.test.ts+++ b/apps/web/__tests__/unit/summary-chapters.test.ts@@ -24,8 +24,11 @@ vi.mock("@/app/s/[videoId]/_components/tabs/SummaryEditor", () => ({SummaryEditor: () => null,}));+import SummaryChapters from "@/app/s/[videoId]/_components/SummaryChapters";import { Summary } from "@/app/s/[videoId]/_components/tabs/Summary";+type Chapter = { title: string; start: number };+let container: HTMLDivElement;let root: Root;@@ -42,9 +45,10 @@ afterEach(() => {vi.unstubAllGlobals();});-const renderChapters = (chapters: { title: string; start: number }[]) => {- act(() => {- root.render(+const chapterViews: [string, (chapters: Chapter[]) => React.ReactElement][] = [+ [+ "Summary tab",+ (chapters) =>React.createElement(Summary, {videoId: "vid" as never,ownerIsPro: true,@@ -54,14 +58,35 @@ const renderChapters = (chapters: { title: string; start: number }[]) => {aiGenerationStatus: "COMPLETE",},}),- );- });- return Array.from(container.querySelectorAll("button"))- .map((button) => button.textContent ?? "")- .filter((text) => /\d:\d\d/.test(text));-};+ ],+ [+ "SummaryChapters",+ (chapters) =>+ React.createElement(SummaryChapters, {+ isSummaryDisabled: false,+ areChaptersDisabled: false,+ handleSeek: () => {},+ aiData: {+ title: null,+ summary: "A summary",+ chapters,+ aiGenerationStatus: "COMPLETE",+ },+ aiLoading: false,+ }),+ ],+];++describe.each(chapterViews)("%s chapter timestamps", (_name, view) => {+ const renderChapters = (chapters: Chapter[]) => {+ act(() => {+ root.render(view(chapters));+ });+ return Array.from(container.querySelectorAll("button"))+ .map((button) => button.textContent ?? "")+ .filter((text) => /\d:\d\d/.test(text));+ };-describe("Summary chapter timestamps", () => {it("rolls over into hours for chapters past the hour mark", () => {const rendered = renderChapters([{ title: "Intro", start: 0 },diff --git a/apps/web/app/s/[videoId]/_components/SummaryChapters.tsx b/apps/web/app/s/[videoId]/_components/SummaryChapters.tsxindex c1b8f9d68..90bba426f 100644--- a/apps/web/app/s/[videoId]/_components/SummaryChapters.tsx+++ b/apps/web/app/s/[videoId]/_components/SummaryChapters.tsx@@ -1,5 +1,5 @@import ReactMarkdown from "react-markdown";-import { formatTimeMinutes } from "./utils/transcript-utils";+import { formatPlayerTime } from "@/lib/player-time";type AiGenerationStatus =| "QUEUED"@@ -64,7 +64,7 @@ const SummaryChapters = ({onClick={() => handleSeek(chapter.start)}><span className="w-16 text-xs text-gray-500">- {formatTimeMinutes(chapter.start)}+ {formatPlayerTime(chapter.start)}</span><span className="ml-2 text-sm">{chapter.title}</span></button>diff --git a/apps/web/app/s/[videoId]/_components/utils/transcript-utils.ts b/apps/web/app/s/[videoId]/_components/utils/transcript-utils.tsindex 97a16a64b..8855f6ec7 100644--- a/apps/web/app/s/[videoId]/_components/utils/transcript-utils.ts+++ b/apps/web/app/s/[videoId]/_components/utils/transcript-utils.ts@@ -20,14 +20,6 @@ export const formatTime = (seconds: number): string => {.padStart(3, "0")}`;};-export const formatTimeMinutes = (time: number) => {- const minutes = Math.floor(time / 60);- const seconds = Math.floor(time % 60);- return `${minutes.toString().padStart(2, "0")}:${seconds- .toString()- .padStart(2, "0")}`;-};-/*** Formats transcript entries as VTT format for subtitles*/