summaryrefslogtreecommitdiff
path: root/ext/js/templates/sandbox/template-renderer-frame-api.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-20 00:18:55 -0500
committerGitHub <noreply@github.com>2023-12-20 05:18:55 +0000
commit3c226215419ca815712e9568f7d871a96f5ff1cf (patch)
tree8bfe561a0d36589860b64c1758c2e29e92e7e3f4 /ext/js/templates/sandbox/template-renderer-frame-api.js
parente0e29dc1aa0965b3e0fb97de64a27c2b695e068b (diff)
Simplify message handlers (#396)
Diffstat (limited to 'ext/js/templates/sandbox/template-renderer-frame-api.js')
-rw-r--r--ext/js/templates/sandbox/template-renderer-frame-api.js14
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/js/templates/sandbox/template-renderer-frame-api.js b/ext/js/templates/sandbox/template-renderer-frame-api.js
index 388401f2..56cedb97 100644
--- a/ext/js/templates/sandbox/template-renderer-frame-api.js
+++ b/ext/js/templates/sandbox/template-renderer-frame-api.js
@@ -27,10 +27,10 @@ export class TemplateRendererFrameApi {
/** @type {import('./template-renderer.js').TemplateRenderer} */
this._templateRenderer = templateRenderer;
/** @type {import('core').MessageHandlerMap} */
- this._windowMessageHandlers = new Map(/** @type {import('core').MessageHandlerArray} */ ([
- ['render', {async: false, handler: this._onRender.bind(this)}],
- ['renderMulti', {async: false, handler: this._onRenderMulti.bind(this)}],
- ['getModifiedData', {async: false, handler: this._onGetModifiedData.bind(this)}]
+ this._windowMessageHandlers = new Map(/** @type {import('core').MessageHandlerMapInit} */ ([
+ ['render', this._onRender.bind(this)],
+ ['renderMulti', this._onRenderMulti.bind(this)],
+ ['getModifiedData', this._onGetModifiedData.bind(this)]
]));
}
@@ -56,17 +56,17 @@ export class TemplateRendererFrameApi {
}
/**
- * @param {import('core').MessageHandlerDetails} handlerItem
+ * @param {import('core').MessageHandler} handler
* @param {string} action
* @param {import('core').SerializableObject} params
* @param {Window} source
* @param {?string} id
*/
- async _onWindowMessageInner({handler, async}, action, params, source, id) {
+ async _onWindowMessageInner(handler, action, params, source, id) {
let response;
try {
let result = handler(params);
- if (async) {
+ if (result instanceof Promise) {
result = await result;
}
response = {result};