aboutsummaryrefslogtreecommitdiff
path: root/src/webex
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-11-02 15:54:43 +0000
committerng0 <ng0@n0.is>2019-11-02 15:54:43 +0000
commit5e05c22c57dfd6ed28516f10e3460567c3bbfc08 (patch)
tree0cfb3ee75054e04f626f6274d4718af2d2bd89e1 /src/webex
parentd5794f507b77110584eb38ec8be362b7ce3cca67 (diff)
parent70a232294035b2a08a701391495b65fdff696b7a (diff)
downloadwallet-core-5e05c22c57dfd6ed28516f10e3460567c3bbfc08.tar.xz
Merge branch 'master' of git.taler.net:wallet-core
Diffstat (limited to 'src/webex')
-rw-r--r--src/webex/background.ts2
-rw-r--r--src/webex/pages/pay.tsx14
-rw-r--r--src/webex/pages/tip.tsx2
-rw-r--r--src/webex/wxApi.ts1
-rw-r--r--src/webex/wxBackend.ts19
5 files changed, 29 insertions, 9 deletions
diff --git a/src/webex/background.ts b/src/webex/background.ts
index 3c63f323e..dbc540df4 100644
--- a/src/webex/background.ts
+++ b/src/webex/background.ts
@@ -23,7 +23,7 @@
/**
* Imports.
*/
-import {wxMain} from "./wxBackend";
+import { wxMain } from "./wxBackend";
window.addEventListener("load", () => {
wxMain();
diff --git a/src/webex/pages/pay.tsx b/src/webex/pages/pay.tsx
index 579688db3..7f2a174b7 100644
--- a/src/webex/pages/pay.tsx
+++ b/src/webex/pages/pay.tsx
@@ -53,6 +53,11 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
return <span>Loading payment information ...</span>;
}
+ let insufficientBalance = false;
+ if (payStatus.status == "insufficient-balance") {
+ insufficientBalance = true;
+ }
+
if (payStatus.status === "error") {
return <span>Error: {payStatus.error}</span>;
}
@@ -93,7 +98,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
const doPayment = async () => {
if (payStatus.status !== "payment-possible") {
- throw Error("invalid state");
+ throw Error(`invalid state: ${payStatus.status}`);
}
const proposalId = payStatus.proposalId;
setNumTries(numTries + 1);
@@ -128,6 +133,12 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
)}
</p>
+ {insufficientBalance ? (
+ <div>
+ <p style={{color: "red", fontWeight: "bold"}}>Unable to pay: Your balance is insufficient.</p>
+ </div>
+ ) : null}
+
{payErrMsg ? (
<div>
<p>Payment failed: {payErrMsg}</p>
@@ -142,6 +153,7 @@ function TalerPayDialog({ talerPayUri }: { talerPayUri: string }) {
<div>
<ProgressButton
loading={loading}
+ disabled={insufficientBalance}
onClick={() => doPayment()}>
{i18n.str`Confirm payment`}
</ProgressButton>
diff --git a/src/webex/pages/tip.tsx b/src/webex/pages/tip.tsx
index 0a066053b..148b8203c 100644
--- a/src/webex/pages/tip.tsx
+++ b/src/webex/pages/tip.tsx
@@ -88,7 +88,7 @@ function TipDisplay(props: { talerTipUri: string }) {
</p>
<form className="pure-form">
<ProgressButton loading={loading} onClick={() => accept()}>
- AcceptTip
+ Accept Tip
</ProgressButton>
{" "}
<button className="pure-button" type="button" onClick={() => discard()}>
diff --git a/src/webex/wxApi.ts b/src/webex/wxApi.ts
index 65c14ac48..39c31ca51 100644
--- a/src/webex/wxApi.ts
+++ b/src/webex/wxApi.ts
@@ -86,6 +86,7 @@ async function callBackend<T extends MessageType>(
return new Promise<MessageMap[T]["response"]>((resolve, reject) => {
chrome.runtime.sendMessage({ type, detail }, (resp) => {
if (typeof resp === "object" && resp && resp.error) {
+ console.warn("response error:", resp)
const e = new WalletApiError(resp.error.message, resp.error);
reject(e);
} else {
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 564ee24f0..16cd2a78c 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -547,19 +547,26 @@ function injectScript(
});
}
-/**
- * Main function to run for the WebExtension backend.
- *
- * Sets up all event handlers and other machinery.
- */
-export async function wxMain() {
+try {
+ // This needs to be outside of main, as Firefox won't fire the event if
+ // the listener isn't created synchronously on loading the backend.
chrome.runtime.onInstalled.addListener(details => {
+ console.log("onInstalled with reason", details.reason);
if (details.reason === "install") {
const url = chrome.extension.getURL("/src/webex/pages/welcome.html");
chrome.tabs.create({ active: true, url: url });
}
});
+} catch (e) {
+ console.error(e);
+}
+/**
+ * Main function to run for the WebExtension backend.
+ *
+ * Sets up all event handlers and other machinery.
+ */
+export async function wxMain() {
// Explicitly unload the extension page as soon as an update is available,
// so the update gets installed as soon as possible.
chrome.runtime.onUpdateAvailable.addListener(details => {