www: add shallow redirection on the final transcript url

This prevent the user waiting for the final generation of the summary to have the final url
It still redirect nextjs internally when final transcript is received.
This commit is contained in:
2023-10-12 11:31:11 +02:00
committed by Mathieu Virbel
parent a50b6e31b2
commit 43016e42aa

View File

@@ -16,6 +16,7 @@ import { faGear } from "@fortawesome/free-solid-svg-icons";
import About from "../../(aboutAndPrivacy)/about";
import Privacy from "../../(aboutAndPrivacy)/privacy";
import { lockWakeState, releaseWakeState } from "../../lib/wakeLock";
import { useRouter } from "next/navigation";
const TranscriptCreate = () => {
const [stream, setStream] = useState<MediaStream | null>(null);
@@ -36,6 +37,7 @@ const TranscriptCreate = () => {
const transcript = useTranscript(stream, api);
const webRTC = useWebRTC(stream, transcript?.response?.id, api);
const webSockets = useWebSockets(transcript?.response?.id);
const router = useRouter();
const {
loading,
permissionOk,
@@ -53,6 +55,17 @@ const TranscriptCreate = () => {
setTranscriptStarted(true);
}, [webSockets.transcriptText]);
useEffect(() => {
if (transcript?.response?.id) {
const newUrl = `/transcripts/${transcript.response.id}`;
// Shallow redirection does not work on NextJS 13
// https://github.com/vercel/next.js/discussions/48110
// https://github.com/vercel/next.js/discussions/49540
// router.push(newUrl, undefined, { shallow: true });
history.replaceState({}, "", newUrl);
}
});
useEffect(() => {
lockWakeState();
return () => {