diff --git a/docs/maps/api-room.md b/docs/maps/api-room.md index 17e3d48e..9d08ce1b 100644 --- a/docs/maps/api-room.md +++ b/docs/maps/api-room.md @@ -81,7 +81,7 @@ WA.room.getCurrentRoom(): Promise ``` Return a promise that resolves to a `Room` object with the following attributes : * **id (string) :** ID of the current room -* **map (ITiledMap) :** contains the JSON map file with the properties that were setted by the script if `setProperty` was called. +* **map (ITiledMap) :** contains the JSON map file with the properties that were set by the script if `setProperty` was called. * **mapUrl (string) :** Url of the JSON map file * **startLayer (string | null) :** Name of the layer where the current user started, only if different from `start` layer diff --git a/front/src/Api/IframeListener.ts b/front/src/Api/IframeListener.ts index 334535a5..314d5d2e 100644 --- a/front/src/Api/IframeListener.ts +++ b/front/src/Api/IframeListener.ts @@ -33,7 +33,7 @@ import { isLoadPageEvent } from "./Events/LoadPageEvent"; import { handleMenuItemRegistrationEvent, isMenuItemRegisterIframeEvent } from "./Events/ui/MenuItemRegisterEvent"; import { SetTilesEvent, isSetTilesEvent } from "./Events/SetTilesEvent"; -type AnswererCallback = (query: IframeQueryMap[T]['query']) => Promise; +type AnswererCallback = (query: IframeQueryMap[T]['query']) => IframeQueryMap[T]['answer']|Promise; /** * Listens to messages from iframes and turn those messages into easy to use observables. @@ -164,7 +164,7 @@ class IframeListener { return; } - answerer(query.data).then((value) => { + Promise.resolve(answerer(query.data)).then((value) => { iframe?.contentWindow?.postMessage({ id: queryId, type: query.type, @@ -411,7 +411,7 @@ class IframeListener { * @param key The "type" of the query we are answering * @param callback */ - public registerAnswerer(key: T, callback: (query: IframeQueryMap[T]['query']) => Promise ): void { + public registerAnswerer(key: T, callback: (query: IframeQueryMap[T]['query']) => IframeQueryMap[T]['answer']|Promise ): void { this.answerers[key] = callback; } diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 6cb5284d..d767f0f4 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -1045,14 +1045,14 @@ ${escapedMessage} ); iframeListener.registerAnswerer('getState', () => { - return Promise.resolve({ + return { mapUrl: this.MapUrlFile, startLayerName: this.startPositionCalculator.startLayerName, uuid: localUserStore.getLocalUser()?.uuid, nickname: localUserStore.getName(), roomId: this.RoomId, tags: this.connection ? this.connection.getAllTags() : [], - }); + }; }); this.iframeSubscriptionList.push( iframeListener.setTilesStream.subscribe((eventTiles) => {