feat: pass userId to getActiveBrowserId

This commit is contained in:
amhsirak
2025-03-06 03:54:44 +05:30
parent 4059e8bd26
commit 57e75a5ce7

View File

@@ -21,12 +21,12 @@ import logger from "../logger";
* @category BrowserManagement-Controller * @category BrowserManagement-Controller
*/ */
export const initializeRemoteBrowserForRecording = (userId: string): string => { export const initializeRemoteBrowserForRecording = (userId: string): string => {
const id = getActiveBrowserId() || uuid(); const id = getActiveBrowserId(userId) || uuid();
createSocketConnection( createSocketConnection(
io.of(id), io.of(id),
async (socket: Socket) => { async (socket: Socket) => {
// browser is already active // browser is already active
const activeId = getActiveBrowserId(); const activeId = getActiveBrowserId(userId);
if (activeId) { if (activeId) {
const remoteBrowser = browserPool.getRemoteBrowser(activeId); const remoteBrowser = browserPool.getRemoteBrowser(activeId);
remoteBrowser?.updateSocket(socket); remoteBrowser?.updateSocket(socket);
@@ -88,8 +88,8 @@ export const destroyRemoteBrowser = async (id: string, userId: string): Promise<
* @returns {string | null} * @returns {string | null}
* @category BrowserManagement-Controller * @category BrowserManagement-Controller
*/ */
export const getActiveBrowserId = (): string | null => { export const getActiveBrowserId = (userId: string): string | null => {
return browserPool.getActiveBrowserId(); return browserPool.getActiveBrowserId(userId);
}; };
/** /**
@@ -127,7 +127,7 @@ export const getRemoteBrowserCurrentTabs = (id: string, userId: string): string[
* @category BrowserManagement-Controller * @category BrowserManagement-Controller
*/ */
export const interpretWholeWorkflow = async (userId: string) => { export const interpretWholeWorkflow = async (userId: string) => {
const id = getActiveBrowserId(); const id = getActiveBrowserId(userId);
if (id) { if (id) {
const browser = browserPool.getRemoteBrowser(id); const browser = browserPool.getRemoteBrowser(id);
if (browser) { if (browser) {
@@ -147,7 +147,7 @@ export const interpretWholeWorkflow = async (userId: string) => {
* @category BrowserManagement-Controller * @category BrowserManagement-Controller
*/ */
export const stopRunningInterpretation = async (userId: string) => { export const stopRunningInterpretation = async (userId: string) => {
const id = getActiveBrowserId(); const id = getActiveBrowserId(userId);
if (id) { if (id) {
const browser = browserPool.getRemoteBrowser(id); const browser = browserPool.getRemoteBrowser(id);
await browser?.stopCurrentInterpretation(); await browser?.stopCurrentInterpretation();