From dd583ca24dd3f95019e5eca58f513375f6a8e8f1 Mon Sep 17 00:00:00 2001 From: ramukaritik Date: Wed, 18 Oct 2023 20:36:25 +0530 Subject: [PATCH] resolved comments --- src/web/client/common/worker/webworker.js | 32 +++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/web/client/common/worker/webworker.js b/src/web/client/common/worker/webworker.js index c293d558..ce55678a 100644 --- a/src/web/client/common/worker/webworker.js +++ b/src/web/client/common/worker/webworker.js @@ -87,7 +87,7 @@ async function loadContainer(config, id, swpId) { const existingMembers = audience.getMembers(); - // TODO: insert user with entity id in container + // TODO: yet to be decided how entity id will be passed in container from vscode side audience.on("memberRemoved", (clientId, member) => { if (!existingMembers.get(member.userId)) { @@ -103,35 +103,39 @@ async function loadContainer(config, id, swpId) { const otherUser = value; const connectionArray = otherUser.connections; - const EntityID = []; + const entityId = []; - for (let i = 0; i < connectionArray.length; i++) { - const connection = connectionArray[i]?.id; - EntityID.push((await container.initialObjects.sharedState.get('selection').get()).get(connection)); - } + const connectionIdInContainer = await (container.initialObjects.sharedState.get('selection').get()); + + connectionArray.forEach((connectionId) => { + entityId.push(connectionIdInContainer.get(connectionId)); + }); self.postMessage({ type: "client-data", userName: otherUser.userName, userId: key, containerId: swpId, - entityId: EntityID, + entityId: entityId, }); }); initial = true; } map.on("valueChanged", async (changed, local) => { - if (!local) { + if (local) { + return; + } else { const otherUser = map.get(changed.key); const connectionArray = otherUser.connections; - const EntityID = []; + const entityId = []; - for (let i = 0; i < connectionArray.length; i++) { - const connection = connectionArray[i]?.id; - EntityID.push((await container.initialObjects.sharedState.get('selection').get()).get(connection)); - } + const connectionIdInContainer = await (container.initialObjects.sharedState.get('selection').get()); + + connectionArray.forEach((connectionId) => { + entityId.push(connectionIdInContainer.get(connectionId)); + }); // eslint-disable-next-line no-undef await self.postMessage({ @@ -139,7 +143,7 @@ async function loadContainer(config, id, swpId) { userId: changed.key, userName: otherUser.userName, containerId: swpId, - entityId: EntityID, + entityId: entityId, }); } });