diff --git a/src/components/Recordings.tsx b/src/components/Recordings.tsx index 252bb336..d42b3a99 100644 --- a/src/components/Recordings.tsx +++ b/src/components/Recordings.tsx @@ -8,6 +8,7 @@ import TranscriptImage from "../images/transcript.svg"; import { Section } from "./Section"; import { Text } from "./Text"; import { MouseEventHandler } from "react"; +import { getTranscriptDisplayPath } from "../transcripts"; interface Props { onRouterStatePushed: () => void; @@ -24,11 +25,7 @@ const RecordingDisplay = ({ const recordingDate = new Date(r.createdAt * 1000); const getTranscriptOnClick = (transcriptUrl: string, startDateTime: Date) => { - const match = transcriptUrl.match(/\/([a-z0-9]{50})\/?$/); - if (!match) { - return; - } - const transcriptId: string = match[1]; + const transcriptPath = getTranscriptDisplayPath(transcriptUrl); const handler: MouseEventHandler = (e) => { // hopefully sufficient magical incantations to prevent the popup e.preventDefault(); @@ -37,7 +34,7 @@ const RecordingDisplay = ({ window.history.pushState( { startDateTime: startDateTime.getTime() }, "", - `/transcript-${transcriptId}`, + transcriptPath, ); onRouterStatePushed(); return false; diff --git a/src/transcripts.ts b/src/transcripts.ts index a978cddb..7d877152 100644 --- a/src/transcripts.ts +++ b/src/transcripts.ts @@ -19,6 +19,17 @@ enum TranscriptDetailsOperation { Finalize, } +export function getTranscriptDisplayPath( + originalTranscriptUrl: string, +): string { + const match = originalTranscriptUrl.match(/\/([a-z0-9]{50})\/?$/); + if (!match) { + throw new Error("No transcript id found in URL"); + } + const transcriptId: string = match[1]; + return `/transcript-${transcriptId}`; +} + const operateOnTranscriptDetails = async ( roomName: string, jwt: string, @@ -188,7 +199,7 @@ export class TranscriptManager { jitsi.executeCommand("showNotification", { title: i18next.t("transcription_link_available_title"), description: i18next.t("transcription_link_available_description", { - transcriptUrl, + transcriptUrl: `${window.location.origin}${getTranscriptDisplayPath(transcriptUrl)}`, }), type: "normal", timeout: "sticky",