Skip to content

Commit

Permalink
fix late meetings
Browse files Browse the repository at this point in the history
  • Loading branch information
sansyrox committed Dec 7, 2024
1 parent b199291 commit 2c1a489
Showing 1 changed file with 35 additions and 18 deletions.
53 changes: 35 additions & 18 deletions extension/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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 <a href='https://amurex.ai/early' target='_blank'>waitlist</a>.",
"To get more suggestions and access to more exciting features, join our early adopters list at <a href='https://amurex.ai/early' target='_blank'>waitlist</a>.",
meetingId: meetingId,
type: "system_notification",
});
Expand Down

0 comments on commit 2c1a489

Please sign in to comment.