Skip to content

Commit

Permalink
Change transcript URL in notification
Browse files Browse the repository at this point in the history
  • Loading branch information
DJAndries committed Jun 25, 2024
1 parent 2d289ed commit 928605c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
9 changes: 3 additions & 6 deletions src/components/Recordings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<HTMLAnchorElement> = (e) => {
// hopefully sufficient magical incantations to prevent the popup
e.preventDefault();
Expand All @@ -37,7 +34,7 @@ const RecordingDisplay = ({
window.history.pushState(
{ startDateTime: startDateTime.getTime() },
"",
`/transcript-${transcriptId}`,
transcriptPath,
);
onRouterStatePushed();
return false;
Expand Down
13 changes: 12 additions & 1 deletion src/transcripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 928605c

Please sign in to comment.