From 16a7a7ebfa7cdad7f5ffcd77fc55271c66562e87 Mon Sep 17 00:00:00 2001 From: sorenjohanson Date: Mon, 23 Dec 2024 11:24:41 +0000 Subject: [PATCH] lint --- .../src/map/services/maps.service.ts | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/teammapper-backend/src/map/services/maps.service.ts b/teammapper-backend/src/map/services/maps.service.ts index 7e5cd87d..f5399794 100644 --- a/teammapper-backend/src/map/services/maps.service.ts +++ b/teammapper-backend/src/map/services/maps.service.ts @@ -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