aboutsummaryrefslogtreecommitdiff
path: root/popup/popup.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'popup/popup.tsx')
-rw-r--r--popup/popup.tsx40
1 files changed, 35 insertions, 5 deletions
diff --git a/popup/popup.tsx b/popup/popup.tsx
index 963556c32..be33f870a 100644
--- a/popup/popup.tsx
+++ b/popup/popup.tsx
@@ -15,6 +15,14 @@
*/
+/**
+ * Popup shown to the user when they click
+ * the Taler browser action button.
+ *
+ * @author Florian Dold
+ */
+
+
/// <reference path="../lib/decl/mithril.d.ts" />
/// <reference path="../lib/decl/lodash.d.ts" />
@@ -87,6 +95,7 @@ namespace WalletBalance {
class Controller {
myWallet;
+ gotError = false;
constructor() {
this.updateBalance();
@@ -96,9 +105,16 @@ namespace WalletBalance {
updateBalance() {
m.startComputation();
- chrome.runtime.sendMessage({type: "balances"}, (wallet) => {
- console.log("got wallet", wallet);
- this.myWallet = wallet;
+ chrome.runtime.sendMessage({type: "balances"}, (resp) => {
+ if (resp.error) {
+ this.gotError = true;
+ console.error("could not retrieve balances", resp);
+ m.endComputation();
+ return;
+ }
+ this.gotError = false;
+ console.log("got wallet", resp);
+ this.myWallet = resp.balances;
m.endComputation();
});
}
@@ -106,6 +122,9 @@ namespace WalletBalance {
export function view(ctrl: Controller) {
let wallet = ctrl.myWallet;
+ if (ctrl.gotError) {
+ return i18n`Error: could not retrieve balance information.`;
+ }
if (!wallet) {
throw Error("Could not retrieve wallet");
}
@@ -192,6 +211,7 @@ namespace WalletHistory {
class Controller {
myHistory;
+ gotError = false;
constructor() {
this.update();
@@ -201,8 +221,15 @@ namespace WalletHistory {
update() {
m.startComputation();
chrome.runtime.sendMessage({type: "get-history"}, (resp) => {
- console.log("got history", history);
- this.myHistory = resp;
+ if (resp.error) {
+ this.gotError = true;
+ console.error("could not retrieve history", resp);
+ m.endComputation();
+ return;
+ }
+ this.gotError = false;
+ console.log("got history", resp.history);
+ this.myHistory = resp.history;
m.endComputation();
});
}
@@ -210,6 +237,9 @@ namespace WalletHistory {
export function view(ctrl: Controller) {
let history = ctrl.myHistory;
+ if (ctrl.gotError) {
+ return i18n`Error: could not retrieve event history`;
+ }
if (!history) {
throw Error("Could not retrieve history");
}