Skip to content

Commit

Permalink
resolved comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikramuka committed Oct 18, 2023
1 parent 5042d4f commit dd583ca
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/web/client/common/worker/webworker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -103,43 +103,47 @@ 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({
type: "client-data",
userId: changed.key,
userName: otherUser.userName,
containerId: swpId,
entityId: EntityID,
entityId: entityId,
});
}
});
Expand Down

0 comments on commit dd583ca

Please sign in to comment.