diff --git a/www/app/[domain]/layout.tsx b/www/app/[domain]/layout.tsx index dbe5ed11..3e881ac3 100644 --- a/www/app/[domain]/layout.tsx +++ b/www/app/[domain]/layout.tsx @@ -11,6 +11,7 @@ import About from "../(aboutAndPrivacy)/about"; import Privacy from "../(aboutAndPrivacy)/privacy"; import { DomainContextProvider } from "./domainContext"; import { getConfig } from "../lib/edgeConfig"; +import { ErrorBoundary } from "@sentry/nextjs"; const poppins = Poppins({ subsets: ["latin"], weight: ["200", "400", "600"] }); @@ -76,80 +77,82 @@ export default async function RootLayout({ children, params }: LayoutProps) { - - -
-
- {/* Logo on the left */} - - Reflector -
-

- Reflector -

-

- Capture the signal, not the noise -

-
- -
- {/* Text link on the right */} + "something went really wrong"

}> + + +
+
+ {/* Logo on the left */} - Create + Reflector +
+

+ Reflector +

+

+ Capture the signal, not the noise +

+
- {browse ? ( - <> -  ·  - - Browse - - - ) : ( - <> - )} -  ·  - - {privacy ? ( - <> -  ·  - - - ) : ( - <> - )} - {requireLogin ? ( - <> -  ·  - - - ) : ( - <> - )} -
-
+
+ {/* Text link on the right */} + + Create + + {browse ? ( + <> +  ·  + + Browse + + + ) : ( + <> + )} +  ·  + + {privacy ? ( + <> +  ·  + + + ) : ( + <> + )} + {requireLogin ? ( + <> +  ·  + + + ) : ( + <> + )} +
+ - {children} -
-
+ {children} + + +
diff --git a/www/app/[domain]/transcripts/[transcriptId]/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/page.tsx index 734f2609..23634b95 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/page.tsx @@ -14,6 +14,7 @@ import QRCode from "react-qr-code"; import TranscriptTitle from "../transcriptTitle"; import Player from "../player"; import WaveformLoading from "../waveformLoading"; +import { useRouter } from "next/navigation"; type TranscriptDetails = { params: { @@ -21,10 +22,11 @@ type TranscriptDetails = { }; }; -const protectedPath = true; +const protectedPath = false; export default function TranscriptDetails(details: TranscriptDetails) { const transcriptId = details.params.transcriptId; + const router = useRouter(); const transcript = useTranscript(protectedPath, transcriptId); const topics = useTopics(protectedPath, transcriptId); @@ -32,15 +34,6 @@ export default function TranscriptDetails(details: TranscriptDetails) { const useActiveTopic = useState(null); const mp3 = useMp3(transcriptId); - if (transcript?.error || topics?.error) { - return ( - - ); - } - useEffect(() => { const statusToRedirect = ["idle", "recording", "processing"]; if (statusToRedirect.includes(transcript.response?.status)) { @@ -48,8 +41,8 @@ export default function TranscriptDetails(details: TranscriptDetails) { // 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); + router.push(newUrl, undefined); + // history.replaceState({}, "", newUrl); } }, [transcript.response?.status]); @@ -60,85 +53,92 @@ export default function TranscriptDetails(details: TranscriptDetails) { .replace(/ +/g, " ") .trim() || ""; + if (transcript.error || topics?.error) { + return ( + + ); + } + + if (transcript?.loading || topics?.loading) { + return ; + } + return ( <> - {transcript?.loading || topics?.loading ? ( - - ) : ( - <> -
- {transcript?.response?.title && ( - + {transcript?.response?.title && ( + + )} + {waveform.waveform && mp3.media ? ( + + ) : waveform.error ? ( +
"error loading this recording"
+ ) : ( + + )} +
+
+ + +
+
+ {transcript.response.longSummary ? ( + - )} - {waveform.waveform && mp3.media ? ( - - ) : waveform.error ? ( -
"error loading this recording"
) : ( - - )} -
-
- - -
-
- {transcript.response.longSummary ? ( - +
+ {transcript.response.status == "processing" ? ( +

Loading Transcript

) : ( -
- {transcript.response.status == "processing" ? ( -

Loading Transcript

- ) : ( -

- There was an error generating the final summary, please - come back later -

- )} -
+

+ There was an error generating the final summary, please come + back later +

)} -
+
+ )} + -
-
- -
-
- -
-
+
+
+
-
- - )} +
+ +
+ +
+ ); } diff --git a/www/app/[domain]/transcripts/useMp3.ts b/www/app/[domain]/transcripts/useMp3.ts index 23249f94..58e0209d 100644 --- a/www/app/[domain]/transcripts/useMp3.ts +++ b/www/app/[domain]/transcripts/useMp3.ts @@ -16,26 +16,30 @@ const useMp3 = (id: string, waiting?: boolean): Mp3Response => { const api = getApi(true); const { api_url } = useContext(DomainContext); const accessTokenInfo = useFiefAccessTokenInfo(); - const [serviceWorkerReady, setServiceWorkerReady] = useState(false); + const [serviceWorker, setServiceWorker] = + useState(null); useEffect(() => { if ("serviceWorker" in navigator) { - navigator.serviceWorker.register("/service-worker.js").then(() => { - setServiceWorkerReady(true); + navigator.serviceWorker.register("/service-worker.js").then((worker) => { + setServiceWorker(worker); }); } + return () => { + serviceWorker?.unregister(); + }; }, []); useEffect(() => { if (!navigator.serviceWorker) return; if (!navigator.serviceWorker.controller) return; - if (!serviceWorkerReady) return; + if (!serviceWorker) return; // Send the token to the service worker navigator.serviceWorker.controller.postMessage({ type: "SET_AUTH_TOKEN", token: accessTokenInfo?.access_token, }); - }, [navigator.serviceWorker, serviceWorkerReady, accessTokenInfo]); + }, [navigator.serviceWorker, !serviceWorker, accessTokenInfo]); useEffect(() => { if (!id || !api || later) return; diff --git a/www/app/[domain]/transcripts/useWaveform.ts b/www/app/[domain]/transcripts/useWaveform.ts index 4073b711..d2bd0fd6 100644 --- a/www/app/[domain]/transcripts/useWaveform.ts +++ b/www/app/[domain]/transcripts/useWaveform.ts @@ -1,8 +1,5 @@ import { useEffect, useState } from "react"; -import { - DefaultApi, - V1TranscriptGetAudioWaveformRequest, -} from "../../api/apis/DefaultApi"; +import { V1TranscriptGetAudioWaveformRequest } from "../../api/apis/DefaultApi"; import { AudioWaveform } from "../../api"; import { useError } from "../../(errors)/errorContext"; import getApi from "../../lib/getApi"; diff --git a/www/app/[domain]/transcripts/useWebSockets.ts b/www/app/[domain]/transcripts/useWebSockets.ts index f289adbb..1e59781c 100644 --- a/www/app/[domain]/transcripts/useWebSockets.ts +++ b/www/app/[domain]/transcripts/useWebSockets.ts @@ -402,6 +402,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { console.debug("WebSocket connection closed"); switch (event.code) { case 1000: // Normal Closure: + case 1005: // Closure by client FF default: setError( new Error(`WebSocket closed unexpectedly with code: ${event.code}`), diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index 1140e555..5527121a 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -3,9 +3,9 @@ import { isDevelopment } from "./utils"; const localConfig = { features: { - requireLogin: false, + requireLogin: true, privacy: true, - browse: false, + browse: true, }, api_url: "http://127.0.0.1:1250", websocket_url: "ws://127.0.0.1:1250", diff --git a/www/app/lib/errorUtils.ts b/www/app/lib/errorUtils.ts index 81a39b5d..e9e5300d 100644 --- a/www/app/lib/errorUtils.ts +++ b/www/app/lib/errorUtils.ts @@ -1,5 +1,8 @@ function shouldShowError(error: Error | null | undefined) { - if (error?.name == "ResponseError" && error["response"].status == 404) + if ( + error?.name == "ResponseError" && + (error["response"].status == 404 || error["response"].status == 403) + ) return false; if (error?.name == "FetchError") return false; return true; diff --git a/www/app/lib/fief.ts b/www/app/lib/fief.ts index 02db67f5..176aa847 100644 --- a/www/app/lib/fief.ts +++ b/www/app/lib/fief.ts @@ -67,7 +67,7 @@ export const getFiefAuthMiddleware = async (url) => { parameters: {}, }, { - matcher: "/transcripts/((?!new).*)", + matcher: "/transcripts/((?!new))", parameters: {}, }, {