From 0472564034cd18c38499f9c84bcdb0dd24e381c9 Mon Sep 17 00:00:00 2001 From: zino Date: Sun, 16 May 2021 01:09:38 +0200 Subject: [PATCH] revised communication --- client/src/modules/communication.ts | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/client/src/modules/communication.ts b/client/src/modules/communication.ts index 53c6dca..40ec435 100644 --- a/client/src/modules/communication.ts +++ b/client/src/modules/communication.ts @@ -12,14 +12,6 @@ export function sendMessage(inData: I.Message, inTo: string): void { child.contentWindow.postMessage(JSON.stringify(inData), "*"); else console.log(`Element with ID ${inTo} does not exist`); - - // if (child === null) { - // console.log(`Element with ID ${inTo} does not exist`); - // return; - // } - - // if (child.contentWindow !== null) - // child.contentWindow.postMessage(JSON.stringify(inData), "*") } } @@ -29,7 +21,7 @@ export function listenToMessages(inHandler: CallableFunction): void { }); } -export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: string, inDate: number = Date.now()) { +export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: string, inDate: number = Date.now()): void { xml.getXMLPromise(inUrl).then((result: unknown): void => { const message: I.Message = { date: inDate, @@ -38,12 +30,13 @@ export function sendXML(inUrl: string, inTo: string, inEvent: string, inFrom: st event: inEvent } sendMessage(message, inTo); - }).catch(function (err) { + }) + .catch(function (err) { console.error(err); }); } -export function sendEventToChild(inEvent: string) { +export function sendEventToChild(inEvent: string): void { const message: I.Message = { message: null, from: "parent", @@ -53,7 +46,7 @@ export function sendEventToChild(inEvent: string) { sendMessage(message, "iframeSeatmap"); } -export function sendEventToParent(inEvent: string) { +export function sendEventToParent(inEvent: string): void { const message: I.Message = { message: null, from: "child", @@ -63,7 +56,7 @@ export function sendEventToParent(inEvent: string) { sendMessage(message, "parent"); } -export function needSeatmapXML(inID: string) { +export function needSeatmapXML(inID: string): void { const message: I.Message = { message: inID, from: "child", @@ -73,14 +66,14 @@ export function needSeatmapXML(inID: string) { sendMessage(message, "parent"); } -export function cancelCheckout(inUrl: string) { +export function cancelCheckout(inUrl: string): void { // use fetch instead of axios because of 302 redirect // see https://github.com/axios/axios/issues/932 fetch(inUrl, { redirect: "manual" - }).then(() => { - console.log(`${inUrl} canceled`); - }).catch(function (error) { + }) + .then(() => console.log(`${inUrl} canceled`)) + .catch(function (error) { console.log("error"); console.log(error); });