diff --git a/www/app/components/dashboard.js b/www/app/components/dashboard.js index 6f4f4b68..d7d5dde9 100644 --- a/www/app/components/dashboard.js +++ b/www/app/components/dashboard.js @@ -11,8 +11,9 @@ export function Dashboard({ finalSummary, topics, disconnected, + useActiveTopic, }) { - const [openIndex, setOpenIndex] = useState(null); + const [activeTopic, setActiveTopic] = useActiveTopic; const [autoscrollEnabled, setAutoscrollEnabled] = useState(true); useEffect(() => { @@ -76,18 +77,26 @@ export function Dashboard({
setOpenIndex(openIndex === index ? null : index)} + onClick={() => + setActiveTopic( + activeTopic == item.timestamp ? null : item.timestamp, + ) + } >
{formatTime(item.timestamp)}
{item.title}
- {openIndex === index && ( + {activeTopic == item.timestamp && (
{item.transcript}
diff --git a/www/app/components/record.js b/www/app/components/record.js index 13f45257..0885b802 100644 --- a/www/app/components/record.js +++ b/www/app/components/record.js @@ -1,6 +1,7 @@ import React, { useRef, useEffect, useState } from "react"; import WaveSurfer from "wavesurfer.js"; +import RegionsPlugin from "wavesurfer.js/dist/plugins/regions"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faDownload } from "@fortawesome/free-solid-svg-icons"; @@ -58,6 +59,9 @@ export default function Recorder(props) { const [currentTime, setCurrentTime] = useState(0); const [timeInterval, setTimeInterval] = useState(null); const [duration, setDuration] = useState(0); + const [waveRegions, setWaveRegions] = useState(null); + + const [activeTopic, setActiveTopic] = props.useActiveTopic; useEffect(() => { document.getElementById("play-btn").disabled = true; @@ -87,6 +91,8 @@ export default function Recorder(props) { _wavesurfer.on("timeupdate", setCurrentTime); setRecord(_wavesurfer.registerPlugin(CustomRecordPlugin.create())); + setWaveRegions(_wavesurfer.registerPlugin(RegionsPlugin.create())); + setWavesurfer(_wavesurfer); return () => { _wavesurfer.destroy(); @@ -103,6 +109,20 @@ export default function Recorder(props) { link.href = record.getRecordedUrl(); link.download = "reflector-recording.webm"; link.style.visibility = "visible"; + + for (let topic of props.topics) { + const region = waveRegions.addRegion({ + start: topic.timestamp, + content: topic.title.slice(0, 7) + "...", + color: "f00", + drag: false, + }); + region.on("click", (e) => { + e.stopPropagation(); + setActiveTopic(region.start); + wavesurfer.setTime(region.start); + }); + } }); } }, [record]); @@ -123,6 +143,12 @@ export default function Recorder(props) { } }, [isRecording]); + useEffect(() => { + if (activeTopic) { + wavesurfer.setTime(activeTopic); + } + }, [activeTopic]); + const handleRecClick = async () => { if (!record) return console.log("no record"); diff --git a/www/app/page.js b/www/app/page.js index 3ebf8e32..c3bcbf3a 100644 --- a/www/app/page.js +++ b/www/app/page.js @@ -10,6 +10,7 @@ import "../public/button.css"; const App = () => { const [stream, setStream] = useState(null); const [disconnected, setDisconnected] = useState(false); + const useActiveTopic = useState(null); useEffect(() => { if (process.env.NEXT_PUBLIC_ENV === "development") { @@ -38,6 +39,8 @@ const App = () => { webRTC?.peer?.send(JSON.stringify({ cmd: "STOP" })); setStream(null); }} + topics={webSockets.topics} + useActiveTopic={useActiveTopic} /> { topics={webSockets.topics} stream={stream} disconnected={disconnected} + useActiveTopic={useActiveTopic} />
);