From 46cfb61cf5533e1f5f849e7de1d312d57e6dcbcc Mon Sep 17 00:00:00 2001
From: Dennis Postma <dennis@directonline.io>
Date: Sat, 4 Jan 2025 23:15:18 +0100
Subject: [PATCH] More map editor work

---
 src/events/gameMaster/mapEditor/list.ts    | 2 +-
 src/events/gameMaster/mapEditor/request.ts | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/events/gameMaster/mapEditor/list.ts b/src/events/gameMaster/mapEditor/list.ts
index c2da2c1..4fd8732 100644
--- a/src/events/gameMaster/mapEditor/list.ts
+++ b/src/events/gameMaster/mapEditor/list.ts
@@ -17,7 +17,7 @@ export default class MapListEvent extends BaseEvent {
 
       const mapRepository = new MapRepository()
       const maps = await mapRepository.getAll()
-      
+
       return callback(maps)
     } catch (error: any) {
       this.logger.error('gm:map:list error', error.message)
diff --git a/src/events/gameMaster/mapEditor/request.ts b/src/events/gameMaster/mapEditor/request.ts
index 4a4399a..67f9c03 100644
--- a/src/events/gameMaster/mapEditor/request.ts
+++ b/src/events/gameMaster/mapEditor/request.ts
@@ -1,5 +1,4 @@
 import { BaseEvent } from '#application/base/baseEvent'
-import Database from '#application/database'
 import { UUID } from '#application/types'
 import { Map } from '#entities/map'
 import MapRepository from '#repositories/mapRepository'
@@ -24,15 +23,16 @@ export default class MapRequestEvent extends BaseEvent {
         return callback(null)
       }
 
-      const map = await MapRepository.getById(data.mapId)
+      const mapRepository = new MapRepository()
+      const map = await mapRepository.getById(data.mapId)
 
       if (!map) {
         this.logger.info(`User ${(await this.getCharacter())!.getId()} tried to request map ${data.mapId} but it does not exist.`)
         return callback(null)
       }
 
-      console.log(map)
-      // await Database.getEntityManager().populate(map, ['mapEventTiles', 'placedMapObjects'])
+      // Populate map with mapEventTiles and placedMapObjects
+      await mapRepository.getEntityManager().populate(map, ['mapEventTiles', 'placedMapObjects'])
 
       return callback(map)
     } catch (error: any) {