From fbba20e1367a6230c501fed832f9f8e221c6603d Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 2 Nov 2023 18:56:09 +0100 Subject: [PATCH 1/4] fixes websockets --- www/app/[domain]/transcripts/useWebSockets.ts | 7 ++++--- www/app/lib/edgeConfig.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/www/app/[domain]/transcripts/useWebSockets.ts b/www/app/[domain]/transcripts/useWebSockets.ts index 6bd7bf48..34f2b413 100644 --- a/www/app/[domain]/transcripts/useWebSockets.ts +++ b/www/app/[domain]/transcripts/useWebSockets.ts @@ -1,7 +1,8 @@ -import { useEffect, useState } from "react"; +import { useContext, useEffect, useState } from "react"; import { Topic, FinalSummary, Status } from "./webSocketTypes"; import { useError } from "../../(errors)/errorContext"; import { useRouter } from "next/navigation"; +import { DomainContext } from "../domainContext"; type UseWebSockets = { transcriptText: string; @@ -148,8 +149,8 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { }; if (!transcriptId) return; - - const url = `${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/v1/transcripts/${transcriptId}/events`; + const { websocket_url } = useContext(DomainContext); + const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`; const ws = new WebSocket(url); ws.onopen = () => { diff --git a/www/app/lib/edgeConfig.ts b/www/app/lib/edgeConfig.ts index 1fdf77b6..5527121a 100644 --- a/www/app/lib/edgeConfig.ts +++ b/www/app/lib/edgeConfig.ts @@ -8,6 +8,7 @@ const localConfig = { browse: true, }, api_url: "http://127.0.0.1:1250", + websocket_url: "ws://127.0.0.1:1250", auth_callback_url: "http://localhost:3000/auth-callback", }; @@ -17,6 +18,7 @@ type EdgeConfig = { [featureName in "requireLogin" | "privacy" | "browse"]: boolean; }; auth_callback_url: string; + websocket_url: string; api_url: string; }; }; From d9cf29123ce82f2c5a7f994d9845fb64bb475d4d Mon Sep 17 00:00:00 2001 From: Sara Date: Thu, 2 Nov 2023 19:19:34 +0100 Subject: [PATCH 2/4] also fix QR code --- www/app/[domain]/transcripts/[transcriptId]/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/app/[domain]/transcripts/[transcriptId]/page.tsx b/www/app/[domain]/transcripts/[transcriptId]/page.tsx index d4f40428..faf50e3a 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/page.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/page.tsx @@ -92,7 +92,7 @@ export default function TranscriptDetails(details: TranscriptDetails) {
From fc0ecaa3d58cca013f2b88e04c4c70b76a417143 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 3 Nov 2023 11:12:17 +0100 Subject: [PATCH 3/4] minor improvements --- www/app/[domain]/domainContext.tsx | 1 + www/app/[domain]/transcripts/useWebSockets.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/www/app/[domain]/domainContext.tsx b/www/app/[domain]/domainContext.tsx index 1228bf8d..1f4957da 100644 --- a/www/app/[domain]/domainContext.tsx +++ b/www/app/[domain]/domainContext.tsx @@ -11,6 +11,7 @@ export const DomainContext = createContext({ browse: false, }, api_url: "", + websocket_url: "", }); export const DomainContextProvider = ({ diff --git a/www/app/[domain]/transcripts/useWebSockets.ts b/www/app/[domain]/transcripts/useWebSockets.ts index 34f2b413..ddb6c576 100644 --- a/www/app/[domain]/transcripts/useWebSockets.ts +++ b/www/app/[domain]/transcripts/useWebSockets.ts @@ -26,6 +26,9 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { const { setError } = useError(); const router = useRouter(); + const { websocket_url } = useContext(DomainContext); + const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`; + useEffect(() => { if (isProcessing || textQueue.length === 0) { return; @@ -149,8 +152,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { }; if (!transcriptId) return; - const { websocket_url } = useContext(DomainContext); - const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`; + const ws = new WebSocket(url); ws.onopen = () => { From ee49970db1a77321a28f771bc4c22cda94efef30 Mon Sep 17 00:00:00 2001 From: Sara Date: Fri, 3 Nov 2023 11:46:13 +0100 Subject: [PATCH 4/4] fix reactivity --- www/app/[domain]/transcripts/useWebSockets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/app/[domain]/transcripts/useWebSockets.ts b/www/app/[domain]/transcripts/useWebSockets.ts index ddb6c576..b7c765ed 100644 --- a/www/app/[domain]/transcripts/useWebSockets.ts +++ b/www/app/[domain]/transcripts/useWebSockets.ts @@ -27,7 +27,6 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { const router = useRouter(); const { websocket_url } = useContext(DomainContext); - const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`; useEffect(() => { if (isProcessing || textQueue.length === 0) { @@ -153,6 +152,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { if (!transcriptId) return; + const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`; const ws = new WebSocket(url); ws.onopen = () => {