From 2c1a48900cccbabb1be4dc2d2df1be78cb9a9c2b Mon Sep 17 00:00:00 2001 From: Sanskar Jethi Date: Sat, 7 Dec 2024 01:26:36 +0000 Subject: [PATCH] fix late meetings --- extension/content.js | 53 +++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/extension/content.js b/extension/content.js index 696199c..62d2c01 100644 --- a/extension/content.js +++ b/extension/content.js @@ -94,26 +94,43 @@ let transcriptProcessingInterval = null; function setupWebSocket() { console.log("Setting up WebSocket"); const meetingId = document.location.pathname.split("/")[1]; - ws = new WebSocket( - `wss://${BASE_URL_BACKEND.replace( - "https://", - "" - )}/ws?meeting_id=${meetingId}` - ); - ws.onopen = () => { - console.log("WebSocket Connected"); - }; + // Get userId first, then set up WebSocket + chrome.runtime.sendMessage( + { + action: "getUserId", + }, + (response) => { + if (chrome.runtime.lastError) { + console.error("Error getting user id:", chrome.runtime.lastError); + return; + } - ws.onclose = () => { - console.log("WebSocket Disconnected"); - // Attempt to reconnect after 5 seconds - setTimeout(setupWebSocket, 5000); - }; + const userId = response.userId; + console.log("User ID:", userId); - ws.onerror = (error) => { - console.error("WebSocket Error:", error); - }; + ws = new WebSocket( + `wss://${BASE_URL_BACKEND.replace( + "https://", + "" + )}/ws?meeting_id=${meetingId}&user_id=${userId}` + ); + + ws.onopen = () => { + console.log("WebSocket Connected"); + }; + + ws.onclose = () => { + console.log("WebSocket Disconnected"); + // Attempt to reconnect after 5 seconds + setTimeout(setupWebSocket, 5000); + }; + + ws.onerror = (error) => { + console.error("WebSocket Error:", error); + }; + } + ); } function checkStoredTranscripts() { @@ -241,7 +258,7 @@ const debouncedDoStuff = async function () { timestamp: new Date().toISOString(), question: "Only limited suggestions allowed per meeting in beta.", answer: - "To get more suggestions and access to more exciting features, join our early adopters list at waitlist.", + "To get more suggestions and access to more exciting features, join our early adopters list at waitlist.", meetingId: meetingId, type: "system_notification", });