Merge pull request #301 from Monadical-SAS/sara/fix-websockets

fixes websockets
This commit is contained in:
Sara
2023-11-03 11:53:55 +01:00
committed by GitHub
4 changed files with 9 additions and 3 deletions

View File

@@ -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;
@@ -25,6 +26,8 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
const { setError } = useError();
const router = useRouter();
const { websocket_url } = useContext(DomainContext);
useEffect(() => {
if (isProcessing || textQueue.length === 0) {
return;
@@ -290,7 +293,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => {
if (!transcriptId) return;
const url = `${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/v1/transcripts/${transcriptId}/events`;
const url = `${websocket_url}/v1/transcripts/${transcriptId}/events`;
const ws = new WebSocket(url);
ws.onopen = () => {