taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit c590e03aea9227cabb91c9e5426a92d2b3cb3bc3
parent 5737c121ca3635a4afee0c017b7652eb39ee4ab1
Author: Florian Dold <florian.dold@gmail.com>
Date:   Fri, 23 Sep 2016 18:28:50 +0200

fix event passing

Diffstat:
Mcontent_scripts/notify.ts | 11+++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/content_scripts/notify.ts b/content_scripts/notify.ts @@ -97,13 +97,19 @@ namespace TalerNotify { */ function addHandler(type: string, handler: HandlerFn) { let handlerWrap = (e: CustomEvent) => { - let callId: number|undefined = e.detail.callId; + if (e.type != type) { + throw Error(`invariant violated`); + } + let callId: number|undefined = undefined; + if (e.detail && e.detail.callId != undefined) { + callId = e.detail.callId; + } let responder = (msg?: any) => { let fullMsg = Object.assign({}, msg, {callId}); let evt = new CustomEvent(type + "-result", {detail: fullMsg}); document.dispatchEvent(evt); }; - handler(e, responder); + handler(e.detail, responder); }; document.addEventListener(type, handlerWrap); handlers.push({type, listener: handlerWrap}); @@ -149,6 +155,7 @@ namespace TalerNotify { addHandler("taler-confirm-contract", (msg: any) => { + console.log("got msg", msg); if (!msg.contract_wrapper) { console.error("contract wrapper missing"); return;