aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2018-03-07 21:15:01 +0100
committerFlorian Dold <florian.dold@gmail.com>2018-03-07 21:15:01 +0100
commitc1b11a66686658ff93f5a0a5c52f4c48127e524b (patch)
treef020df3ad6081b673bd3635fa16538156eb540a6
parent922f628feddac6d5a40e33516a529f93beddbce4 (diff)
fix merchant page event handling, remove taler-pay for now
-rw-r--r--src/webex/notify.ts20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/webex/notify.ts b/src/webex/notify.ts
index e163a6272..4e53c3e1f 100644
--- a/src/webex/notify.ts
+++ b/src/webex/notify.ts
@@ -141,15 +141,19 @@ function registerHandlers() {
*/
function addHandler(type: string, handler: HandlerFn) {
const handlerWrap = (e: Event) => {
- if (!(e instanceof CustomEvent)) {
+ if (!(e instanceof Event)) {
+ console.log("unexpected event", e);
throw Error(`invariant violated`);
}
if (e.type !== type) {
+ console.log("unexpected event type", e);
throw Error(`invariant violated`);
}
- let callId: number|undefined;
- if (e.detail && e.detail.callId !== undefined) {
+ let callId: number | undefined;
+ let detail;
+ if ((e instanceof CustomEvent) && e.detail && e.detail.callId !== undefined) {
callId = e.detail.callId;
+ detail = e.detail;
}
const responder = (msg?: any) => {
const fullMsg = Object.assign({}, msg, {callId});
@@ -160,16 +164,15 @@ function registerHandlers() {
const evt = new CustomEvent(type + "-result", opts);
document.dispatchEvent(evt);
};
- handler(e.detail, responder);
+ handler(detail, responder);
};
document.addEventListener(type, handlerWrap);
handlers.push({type, listener: handlerWrap});
}
-
addHandler("taler-query-id", (msg: any, sendResponse: any) => {
// FIXME: maybe include this info in taler-probe?
- sendResponse({id: chrome.runtime.id});
+ sendResponse({ id: chrome.runtime.id });
});
addHandler("taler-probe", (msg: any, sendResponse: any) => {
@@ -207,11 +210,6 @@ function registerHandlers() {
await wxApi.confirmReserve(msg.reserve_pub);
sendResponse();
});
-
- addHandler("taler-pay", async(msg: any, sendResponse: any) => {
- const resp = await wxApi.talerPay(msg);
- sendResponse(resp);
- });
}
logVerbose && console.log("loading Taler content script");