mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
Final touches and testing
This commit is contained in:
@@ -92,7 +92,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
|||||||
<Player
|
<Player
|
||||||
topics={topics?.topics || []}
|
topics={topics?.topics || []}
|
||||||
useActiveTopic={useActiveTopic}
|
useActiveTopic={useActiveTopic}
|
||||||
waveform={waveform.waveform.data}
|
waveform={waveform.waveform}
|
||||||
media={mp3.media}
|
media={mp3.media}
|
||||||
mediaDuration={transcript.response.duration}
|
mediaDuration={transcript.response.duration}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type PlayerProps = {
|
|||||||
Topic | null,
|
Topic | null,
|
||||||
React.Dispatch<React.SetStateAction<Topic | null>>,
|
React.Dispatch<React.SetStateAction<Topic | null>>,
|
||||||
];
|
];
|
||||||
waveform: AudioWaveform["data"];
|
waveform: AudioWaveform;
|
||||||
media: HTMLMediaElement;
|
media: HTMLMediaElement;
|
||||||
mediaDuration: number;
|
mediaDuration: number;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import "../../styles/button.css";
|
|||||||
import "../../styles/form.scss";
|
import "../../styles/form.scss";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
|
import { faSpinner } from "@fortawesome/free-solid-svg-icons";
|
||||||
import { DefaultService, UpdateTranscript } from "../../api";
|
import { UpdateTranscript } from "../../api";
|
||||||
import { ShareMode, toShareMode } from "../../lib/shareMode";
|
import { ShareMode, toShareMode } from "../../lib/shareMode";
|
||||||
import useApi from "../../lib/useApi";
|
import useApi from "../../lib/useApi";
|
||||||
type ShareLinkProps = {
|
type ShareLinkProps = {
|
||||||
@@ -18,7 +18,6 @@ type ShareLinkProps = {
|
|||||||
|
|
||||||
const ShareLink = (props: ShareLinkProps) => {
|
const ShareLink = (props: ShareLinkProps) => {
|
||||||
const [isCopied, setIsCopied] = useState(false);
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
const [api, setApi] = useState<DefaultService | null>(null);
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const [currentUrl, setCurrentUrl] = useState<string>("");
|
const [currentUrl, setCurrentUrl] = useState<string>("");
|
||||||
const requireLogin = featureEnabled("requireLogin");
|
const requireLogin = featureEnabled("requireLogin");
|
||||||
@@ -26,11 +25,10 @@ const ShareLink = (props: ShareLinkProps) => {
|
|||||||
const [shareMode, setShareMode] = useState<ShareMode>(props.shareMode);
|
const [shareMode, setShareMode] = useState<ShareMode>(props.shareMode);
|
||||||
const [shareLoading, setShareLoading] = useState(false);
|
const [shareLoading, setShareLoading] = useState(false);
|
||||||
const userinfo = useFiefUserinfo();
|
const userinfo = useFiefUserinfo();
|
||||||
|
const api = useApi();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentUrl(window.location.href);
|
setCurrentUrl(window.location.href);
|
||||||
const api = useApi();
|
|
||||||
setApi(api);
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -51,14 +49,13 @@ const ShareLink = (props: ShareLinkProps) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateShareMode = async (selectedShareMode: string) => {
|
const updateShareMode = async (selectedShareMode: string) => {
|
||||||
|
if (!api)
|
||||||
|
throw new Error("ShareLink's API should always be ready at this point");
|
||||||
|
|
||||||
setShareLoading(true);
|
setShareLoading(true);
|
||||||
const requestBody: UpdateTranscript = {
|
const requestBody: UpdateTranscript = {
|
||||||
share_mode: toShareMode(selectedShareMode),
|
share_mode: toShareMode(selectedShareMode),
|
||||||
};
|
};
|
||||||
const api = useApi();
|
|
||||||
|
|
||||||
if (!api)
|
|
||||||
throw new Error("ShareLink's API should always be ready at this point");
|
|
||||||
|
|
||||||
const updatedTranscript = await api.v1TranscriptUpdate(
|
const updatedTranscript = await api.v1TranscriptUpdate(
|
||||||
props.transcriptId,
|
props.transcriptId,
|
||||||
@@ -68,7 +65,6 @@ const ShareLink = (props: ShareLinkProps) => {
|
|||||||
setShareLoading(false);
|
setShareLoading(false);
|
||||||
};
|
};
|
||||||
const privacyEnabled = featureEnabled("privacy");
|
const privacyEnabled = featureEnabled("privacy");
|
||||||
const apiReady = api != null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@@ -89,8 +85,8 @@ const ShareLink = (props: ShareLinkProps) => {
|
|||||||
<p>This transcript is public. Everyone can access it.</p>
|
<p>This transcript is public. Everyone can access it.</p>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isOwner &&
|
{isOwner && api && (
|
||||||
apiReady(
|
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<SelectSearch
|
<SelectSearch
|
||||||
className="select-search--top select-search"
|
className="select-search--top select-search"
|
||||||
@@ -111,7 +107,7 @@ const ShareLink = (props: ShareLinkProps) => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>,
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useState } from "react";
|
||||||
import { UpdateTranscript } from "../../api";
|
import { UpdateTranscript } from "../../api";
|
||||||
import useApi from "../../lib/useApi";
|
import useApi from "../../lib/useApi";
|
||||||
|
|
||||||
@@ -11,8 +11,10 @@ const TranscriptTitle = (props: TranscriptTitle) => {
|
|||||||
const [displayedTitle, setDisplayedTitle] = useState(props.title);
|
const [displayedTitle, setDisplayedTitle] = useState(props.title);
|
||||||
const [preEditTitle, setPreEditTitle] = useState(props.title);
|
const [preEditTitle, setPreEditTitle] = useState(props.title);
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
|
const api = useApi();
|
||||||
|
|
||||||
const updateTitle = async (newTitle: string, transcriptId: string) => {
|
const updateTitle = async (newTitle: string, transcriptId: string) => {
|
||||||
|
if (!api) return;
|
||||||
try {
|
try {
|
||||||
const requestBody: UpdateTranscript = {
|
const requestBody: UpdateTranscript = {
|
||||||
title: newTitle,
|
title: newTitle,
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ const useTranscript = (
|
|||||||
}
|
}
|
||||||
setErrorState(error);
|
setErrorState(error);
|
||||||
});
|
});
|
||||||
}, [id, api]);
|
}, [id, !api]);
|
||||||
|
|
||||||
return { response, loading, error } as
|
return { response, loading, error } as
|
||||||
| ErrorTranscript
|
| ErrorTranscript
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ const useTranscriptList = (page: number): TranscriptList => {
|
|||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setLoading(true);
|
|
||||||
if (!api) return;
|
if (!api) return;
|
||||||
|
setLoading(true);
|
||||||
api
|
api
|
||||||
.v1TranscriptsList(page)
|
.v1TranscriptsList(page)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
@@ -32,7 +32,7 @@ const useTranscriptList = (page: number): TranscriptList => {
|
|||||||
setError(err);
|
setError(err);
|
||||||
setErrorState(err);
|
setErrorState(err);
|
||||||
});
|
});
|
||||||
}, [api, page]);
|
}, [!api, page]);
|
||||||
|
|
||||||
return { response, loading, error };
|
return { response, loading, error };
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const useWebRTC = (
|
|||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!stream || !transcriptId || !api) {
|
if (!stream || !transcriptId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useContext, useEffect, useState } from "react";
|
|||||||
import { Topic, FinalSummary, Status } from "./webSocketTypes";
|
import { Topic, FinalSummary, Status } from "./webSocketTypes";
|
||||||
import { useError } from "../../(errors)/errorContext";
|
import { useError } from "../../(errors)/errorContext";
|
||||||
import { DomainContext } from "../domainContext";
|
import { DomainContext } from "../domainContext";
|
||||||
import { AudioWaveform } from "../../api";
|
import { AudioWaveform, GetTranscriptSegmentTopic } from "../../api";
|
||||||
|
|
||||||
export type UseWebSockets = {
|
export type UseWebSockets = {
|
||||||
transcriptText: string;
|
transcriptText: string;
|
||||||
@@ -11,7 +11,7 @@ export type UseWebSockets = {
|
|||||||
topics: Topic[];
|
topics: Topic[];
|
||||||
finalSummary: FinalSummary;
|
finalSummary: FinalSummary;
|
||||||
status: Status;
|
status: Status;
|
||||||
waveform: AudioWaveform["data"] | null;
|
waveform: AudioWaveform | null;
|
||||||
duration: number | null;
|
duration: number | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -57,17 +57,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
document.onkeyup = (e) => {
|
document.onkeyup = (e) => {
|
||||||
if (e.key === "a" && process.env.NEXT_PUBLIC_ENV === "development") {
|
if (e.key === "a" && process.env.NEXT_PUBLIC_ENV === "development") {
|
||||||
setTranscriptText("Lorem Ipsum");
|
const segments : GetTranscriptSegmentTopic[] = [
|
||||||
setTopics([
|
|
||||||
{
|
|
||||||
id: "1",
|
|
||||||
timestamp: 10,
|
|
||||||
duration: 10,
|
|
||||||
summary: "This is test topic 1",
|
|
||||||
title: "Topic 1: Introduction to Quantum Mechanics",
|
|
||||||
transcript:
|
|
||||||
"A brief overview of quantum mechanics and its principles.",
|
|
||||||
segments: [
|
|
||||||
{
|
{
|
||||||
speaker: 1,
|
speaker: 1,
|
||||||
start: 0,
|
start: 0,
|
||||||
@@ -78,7 +68,6 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
|||||||
start: 10,
|
start: 10,
|
||||||
text: "This is the second speaker",
|
text: "This is the second speaker",
|
||||||
},
|
},
|
||||||
,
|
|
||||||
{
|
{
|
||||||
speaker: 3,
|
speaker: 3,
|
||||||
start: 90,
|
start: 90,
|
||||||
@@ -98,8 +87,19 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
|
|||||||
speaker: 6,
|
speaker: 6,
|
||||||
start: 300,
|
start: 300,
|
||||||
text: "This is the sixth speaker",
|
text: "This is the sixth speaker",
|
||||||
},
|
}
|
||||||
],
|
];
|
||||||
|
|
||||||
|
setTranscriptText("Lorem Ipsum");
|
||||||
|
setTopics([
|
||||||
|
{
|
||||||
|
id: "1",
|
||||||
|
timestamp: 10,
|
||||||
|
duration: 10,
|
||||||
|
summary: "This is test topic 1",
|
||||||
|
title: "Topic 1: Introduction to Quantum Mechanics",
|
||||||
|
transcript:
|
||||||
|
"A brief overview of quantum mechanics and its principles.",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: "2",
|
id: "2",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ export default function useApi(): DefaultService | null {
|
|||||||
const accessTokenInfo = useFiefAccessTokenInfo();
|
const accessTokenInfo = useFiefAccessTokenInfo();
|
||||||
const api_url = useContext(DomainContext).api_url;
|
const api_url = useContext(DomainContext).api_url;
|
||||||
const requireLogin = featureEnabled("requireLogin");
|
const requireLogin = featureEnabled("requireLogin");
|
||||||
const [ready, setReady] = useState<boolean>(false);
|
|
||||||
const [api, setApi] = useState<OpenApi | null>(null);
|
const [api, setApi] = useState<OpenApi | null>(null);
|
||||||
const { hasAuthCookie } = useContext(CookieContext);
|
const { hasAuthCookie } = useContext(CookieContext);
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function getZulipMessage(
|
|||||||
topics: GetTranscriptTopic[] | null,
|
topics: GetTranscriptTopic[] | null,
|
||||||
includeTopics: boolean,
|
includeTopics: boolean,
|
||||||
) {
|
) {
|
||||||
const date = new Date(transcript.createdAt);
|
const date = new Date(transcript.created_at);
|
||||||
|
|
||||||
// Get the timezone offset in minutes and convert it to hours and minutes
|
// Get the timezone offset in minutes and convert it to hours and minutes
|
||||||
const timezoneOffset = -date.getTimezoneOffset();
|
const timezoneOffset = -date.getTimezoneOffset();
|
||||||
@@ -72,7 +72,7 @@ export function getZulipMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let summary = "```spoiler Summary\n";
|
let summary = "```spoiler Summary\n";
|
||||||
summary += transcript.longSummary;
|
summary += transcript.long_summary;
|
||||||
summary += "```\n\n";
|
summary += "```\n\n";
|
||||||
|
|
||||||
const message = headerText + summary + topicText + "-----\n";
|
const message = headerText + summary + topicText + "-----\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user