diff options
Diffstat (limited to 'src/content_scripts/notify.ts')
-rw-r--r-- | src/content_scripts/notify.ts | 75 |
1 files changed, 22 insertions, 53 deletions
diff --git a/src/content_scripts/notify.ts b/src/content_scripts/notify.ts index 582375e1d..a731e4da1 100644 --- a/src/content_scripts/notify.ts +++ b/src/content_scripts/notify.ts @@ -76,20 +76,6 @@ namespace TalerNotify { }); } - function checkRepurchase(contract: string): Promise<any> { - const walletMsg = { - type: "check-repurchase", - detail: { - contract: contract - }, - }; - return new Promise((resolve, reject) => { - chrome.runtime.sendMessage(walletMsg, (resp: any) => { - resolve(resp); - }); - }); - } - function queryPayment(query: any): Promise<any> { // current URL without fragment const walletMsg = { @@ -239,49 +225,32 @@ namespace TalerNotify { return; } - let resp = await checkRepurchase(proposal.data); - - if (resp.error) { - console.error("wallet backend error", resp); - return; + let merchantName = "(unknown)"; + try { + merchantName = proposal.data.merchant.name; + } catch (e) { + // bad contract / name not included } - if (resp.isRepurchase) { - logVerbose && console.log("doing repurchase"); - console.assert(resp.existingFulfillmentUrl); - console.assert(resp.existingContractHash); - window.location.href = subst(resp.existingFulfillmentUrl, - resp.existingContractHash); - - } else { - - let merchantName = "(unknown)"; - try { - merchantName = proposal.data.merchant.name; - } catch (e) { - // bad contract / name not included + let historyEntry = { + timestamp: (new Date).getTime(), + subjectId: `contract-${contractHash}`, + type: "offer-contract", + detail: { + contractHash, + merchantName, } + }; + await putHistory(historyEntry); + let offerId = await saveOffer(proposal); - let historyEntry = { - timestamp: (new Date).getTime(), - subjectId: `contract-${contractHash}`, - type: "offer-contract", - detail: { - contractHash, - merchantName, - } - }; - await putHistory(historyEntry); - let offerId = await saveOffer(proposal); - - const uri = URI(chrome.extension.getURL( - "/src/pages/confirm-contract.html")); - const params = { - offerId: offerId.toString(), - }; - const target = uri.query(params).href(); - document.location.replace(target); - } + const uri = URI(chrome.extension.getURL( + "/src/pages/confirm-contract.html")); + const params = { + offerId: offerId.toString(), + }; + const target = uri.query(params).href(); + document.location.replace(target); } function registerHandlers() { |