mirror of
https://github.com/Monadical-SAS/reflector.git
synced 2025-12-20 20:29:06 +00:00
www: fix loading of past transcript before the user is authenticated
This commit is contained in:
@@ -13,6 +13,8 @@ import FinalSummary from "../finalSummary";
|
|||||||
import ShareLink from "../shareLink";
|
import ShareLink from "../shareLink";
|
||||||
import QRCode from "react-qr-code";
|
import QRCode from "react-qr-code";
|
||||||
import TranscriptTitle from "../transcriptTitle";
|
import TranscriptTitle from "../transcriptTitle";
|
||||||
|
import { featRequireLogin } from "../../../app/lib/utils";
|
||||||
|
import { useFiefIsAuthenticated } from "@fief/fief/nextjs/react";
|
||||||
|
|
||||||
type TranscriptDetails = {
|
type TranscriptDetails = {
|
||||||
params: {
|
params: {
|
||||||
@@ -21,13 +23,20 @@ type TranscriptDetails = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function TranscriptDetails(details: TranscriptDetails) {
|
export default function TranscriptDetails(details: TranscriptDetails) {
|
||||||
|
const isAuthenticated = useFiefIsAuthenticated();
|
||||||
const api = getApi();
|
const api = getApi();
|
||||||
const transcript = useTranscript(details.params.transcriptId);
|
const [transcriptId, setTranscriptId] = useState<string>("");
|
||||||
const topics = useTopics(api, details.params.transcriptId);
|
const transcript = useTranscript(api, transcriptId);
|
||||||
const waveform = useWaveform(api, details.params.transcriptId);
|
const topics = useTopics(api, transcriptId);
|
||||||
|
const waveform = useWaveform(api, transcriptId);
|
||||||
const useActiveTopic = useState<Topic | null>(null);
|
const useActiveTopic = useState<Topic | null>(null);
|
||||||
|
|
||||||
if (transcript?.error || topics?.error || waveform?.error) {
|
useEffect(() => {
|
||||||
|
if (featRequireLogin() && !isAuthenticated) return;
|
||||||
|
setTranscriptId(details.params.transcriptId);
|
||||||
|
}, [api]);
|
||||||
|
|
||||||
|
if (transcript?.error /** || topics?.error || waveform?.error **/) {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title="Transcription Not Found"
|
title="Transcription Not Found"
|
||||||
@@ -45,9 +54,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{transcript?.loading === true ||
|
{transcript?.loading === true || topics?.loading == true ? (
|
||||||
waveform?.loading == true ||
|
|
||||||
topics?.loading == true ? (
|
|
||||||
<Modal title="Loading" text={"Loading transcript..."} />
|
<Modal title="Loading" text={"Loading transcript..."} />
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
@@ -55,13 +62,15 @@ export default function TranscriptDetails(details: TranscriptDetails) {
|
|||||||
{transcript?.response?.title && (
|
{transcript?.response?.title && (
|
||||||
<TranscriptTitle title={transcript.response.title} />
|
<TranscriptTitle title={transcript.response.title} />
|
||||||
)}
|
)}
|
||||||
<Recorder
|
{waveform?.loading == true && (
|
||||||
topics={topics?.topics || []}
|
<Recorder
|
||||||
useActiveTopic={useActiveTopic}
|
topics={topics?.topics || []}
|
||||||
waveform={waveform?.waveform}
|
useActiveTopic={useActiveTopic}
|
||||||
isPastMeeting={true}
|
waveform={waveform?.waveform}
|
||||||
transcriptId={transcript?.response?.id}
|
isPastMeeting={true}
|
||||||
/>
|
transcriptId={transcript?.response?.id}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 grid-rows-2 lg:grid-rows-1 gap-2 lg:gap-4 h-full">
|
<div className="grid grid-cols-1 lg:grid-cols-2 grid-rows-2 lg:grid-rows-1 gap-2 lg:gap-4 h-full">
|
||||||
<TopicList
|
<TopicList
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ const TranscriptRecord = (details: TranscriptDetails) => {
|
|||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const transcript = useTranscript(details.params.transcriptId);
|
|
||||||
const api = getApi();
|
const api = getApi();
|
||||||
|
const transcript = useTranscript(api, details.params.transcriptId);
|
||||||
const webRTC = useWebRTC(stream, details.params.transcriptId, api);
|
const webRTC = useWebRTC(stream, details.params.transcriptId, api);
|
||||||
const webSockets = useWebSockets(details.params.transcriptId);
|
const webSockets = useWebSockets(details.params.transcriptId);
|
||||||
|
|
||||||
|
|||||||
@@ -13,15 +13,14 @@ type TranscriptTopics = {
|
|||||||
error: Error | null;
|
error: Error | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useTranscript = (api: DefaultApi, id: string): TranscriptTopics => {
|
const useTopics = (api: DefaultApi, id: string): TranscriptTopics => {
|
||||||
const [topics, setTopics] = useState<Topic[] | null>(null);
|
const [topics, setTopics] = useState<Topic[] | null>(null);
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [error, setErrorState] = useState<Error | null>(null);
|
const [error, setErrorState] = useState<Error | null>(null);
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
|
|
||||||
const getTopics = (id: string) => {
|
const getTopics = (id: string) => {
|
||||||
if (!id)
|
if (!id) return;
|
||||||
throw new Error("Transcript ID is required to get transcript topics");
|
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const requestParameters: V1TranscriptGetTopicsRequest = {
|
const requestParameters: V1TranscriptGetTopicsRequest = {
|
||||||
@@ -47,4 +46,4 @@ const useTranscript = (api: DefaultApi, id: string): TranscriptTopics => {
|
|||||||
return { topics, loading, error };
|
return { topics, loading, error };
|
||||||
};
|
};
|
||||||
|
|
||||||
export default useTranscript;
|
export default useTopics;
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import {
|
import { DefaultApi, V1TranscriptGetRequest } from "../api/apis/DefaultApi";
|
||||||
V1TranscriptGetRequest,
|
|
||||||
V1TranscriptsCreateRequest,
|
|
||||||
} from "../api/apis/DefaultApi";
|
|
||||||
import { GetTranscript } from "../api";
|
import { GetTranscript } from "../api";
|
||||||
import { useError } from "../(errors)/errorContext";
|
import { useError } from "../(errors)/errorContext";
|
||||||
import getApi from "../lib/getApi";
|
|
||||||
|
|
||||||
type Transcript = {
|
type Transcript = {
|
||||||
response: GetTranscript | null;
|
response: GetTranscript | null;
|
||||||
@@ -13,15 +9,14 @@ type Transcript = {
|
|||||||
error: Error | null;
|
error: Error | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useTranscript = (id: string | null): Transcript => {
|
const useTranscript = (api: DefaultApi, id: string | null): Transcript => {
|
||||||
const [response, setResponse] = useState<GetTranscript | null>(null);
|
const [response, setResponse] = useState<GetTranscript | null>(null);
|
||||||
const [loading, setLoading] = useState<boolean>(false);
|
const [loading, setLoading] = useState<boolean>(false);
|
||||||
const [error, setErrorState] = useState<Error | null>(null);
|
const [error, setErrorState] = useState<Error | null>(null);
|
||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
const api = getApi();
|
|
||||||
|
|
||||||
const getTranscript = (id: string | null) => {
|
const getTranscript = (id: string | null) => {
|
||||||
if (!id) throw new Error("Transcript ID is required to get transcript");
|
if (!id) return;
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const requestParameters: V1TranscriptGetRequest = {
|
const requestParameters: V1TranscriptGetRequest = {
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ const useWaveform = (api: DefaultApi, id: string): AudioWaveFormResponse => {
|
|||||||
const { setError } = useError();
|
const { setError } = useError();
|
||||||
|
|
||||||
const getWaveform = (id: string) => {
|
const getWaveform = (id: string) => {
|
||||||
if (!id)
|
if (!id) return;
|
||||||
throw new Error("Transcript ID is required to get transcript waveform");
|
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const requestParameters: V1TranscriptGetAudioWaveformRequest = {
|
const requestParameters: V1TranscriptGetAudioWaveformRequest = {
|
||||||
|
|||||||
Reference in New Issue
Block a user