Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenjohanson committed Dec 23, 2024
1 parent f486a43 commit 16a7a7e
Showing 1 changed file with 29 additions and 16 deletions.
45 changes: 29 additions & 16 deletions teammapper-backend/src/map/services/maps.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,37 @@ export class MapsService {
) => {
await Promise.all(
Object.keys(diff).map(async (key) => {
const clientNode = diff[key]

if (clientNode) {
const serverNode = await this.nodesRepository.findOne({ where: { nodeMapId: mapId, id: key } });

if (serverNode) {
const mergedNode = mergeClientNodeIntoMmpNode(clientNode, serverNode);
Object.assign(serverNode, mergedNode);
try {
await this.nodesRepository.save(serverNode);
} catch (error) {
this.logger.warn(`${error.constructor.name} diffUpdatedCallback(): Failed to update node ${serverNode.id}: ${error}`)
return Promise.reject(error)
}
const clientNode = diff[key];

if (!clientNode) {
return;
}

const serverNode = await this.nodesRepository.findOne({
where: {
nodeMapId: mapId,
id: key
}
});

if (!serverNode) {
return;
}

const mergedNode = mergeClientNodeIntoMmpNode(clientNode, serverNode);
Object.assign(serverNode, mergedNode);

try {
await this.nodesRepository.save(serverNode);
} catch (error) {
this.logger.warn(
`${error.constructor.name} diffUpdatedCallback(): Failed to update node ${serverNode.id}: ${error}`
);
return Promise.reject(error);
}
})
)
}
);
};

const diffDeletedCallback: DiffCallback = async (
diff: IMmpClientSnapshotChanges
Expand Down

0 comments on commit 16a7a7e

Please sign in to comment.