fix merchant page event handling, remove taler-pay for now
This commit is contained in:
parent
922f628fed
commit
c1b11a6668
@ -141,15 +141,19 @@ function registerHandlers() {
|
|||||||
*/
|
*/
|
||||||
function addHandler(type: string, handler: HandlerFn) {
|
function addHandler(type: string, handler: HandlerFn) {
|
||||||
const handlerWrap = (e: Event) => {
|
const handlerWrap = (e: Event) => {
|
||||||
if (!(e instanceof CustomEvent)) {
|
if (!(e instanceof Event)) {
|
||||||
|
console.log("unexpected event", e);
|
||||||
throw Error(`invariant violated`);
|
throw Error(`invariant violated`);
|
||||||
}
|
}
|
||||||
if (e.type !== type) {
|
if (e.type !== type) {
|
||||||
|
console.log("unexpected event type", e);
|
||||||
throw Error(`invariant violated`);
|
throw Error(`invariant violated`);
|
||||||
}
|
}
|
||||||
let callId: number|undefined;
|
let callId: number | undefined;
|
||||||
if (e.detail && e.detail.callId !== undefined) {
|
let detail;
|
||||||
|
if ((e instanceof CustomEvent) && e.detail && e.detail.callId !== undefined) {
|
||||||
callId = e.detail.callId;
|
callId = e.detail.callId;
|
||||||
|
detail = e.detail;
|
||||||
}
|
}
|
||||||
const responder = (msg?: any) => {
|
const responder = (msg?: any) => {
|
||||||
const fullMsg = Object.assign({}, msg, {callId});
|
const fullMsg = Object.assign({}, msg, {callId});
|
||||||
@ -160,16 +164,15 @@ function registerHandlers() {
|
|||||||
const evt = new CustomEvent(type + "-result", opts);
|
const evt = new CustomEvent(type + "-result", opts);
|
||||||
document.dispatchEvent(evt);
|
document.dispatchEvent(evt);
|
||||||
};
|
};
|
||||||
handler(e.detail, responder);
|
handler(detail, responder);
|
||||||
};
|
};
|
||||||
document.addEventListener(type, handlerWrap);
|
document.addEventListener(type, handlerWrap);
|
||||||
handlers.push({type, listener: handlerWrap});
|
handlers.push({type, listener: handlerWrap});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addHandler("taler-query-id", (msg: any, sendResponse: any) => {
|
addHandler("taler-query-id", (msg: any, sendResponse: any) => {
|
||||||
// FIXME: maybe include this info in taler-probe?
|
// 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) => {
|
addHandler("taler-probe", (msg: any, sendResponse: any) => {
|
||||||
@ -207,11 +210,6 @@ function registerHandlers() {
|
|||||||
await wxApi.confirmReserve(msg.reserve_pub);
|
await wxApi.confirmReserve(msg.reserve_pub);
|
||||||
sendResponse();
|
sendResponse();
|
||||||
});
|
});
|
||||||
|
|
||||||
addHandler("taler-pay", async(msg: any, sendResponse: any) => {
|
|
||||||
const resp = await wxApi.talerPay(msg);
|
|
||||||
sendResponse(resp);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logVerbose && console.log("loading Taler content script");
|
logVerbose && console.log("loading Taler content script");
|
||||||
|
Loading…
Reference in New Issue
Block a user