aboutsummaryrefslogtreecommitdiff
path: root/lib/wallet
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-05-24 02:05:19 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-05-24 02:05:19 +0200
commitce7f7b8321c89f9bdd62e9b148181865f8834871 (patch)
treed6a8a684779ec4252a69e4a6618a7ff2671c6383 /lib/wallet
parent741dff270689ce8a16359e116f8e7dd02dd74c09 (diff)
downloadwallet-core-ce7f7b8321c89f9bdd62e9b148181865f8834871.tar.xz
show progress
Diffstat (limited to 'lib/wallet')
-rw-r--r--lib/wallet/wallet.ts21
-rw-r--r--lib/wallet/wxMessaging.ts8
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/wallet/wallet.ts b/lib/wallet/wallet.ts
index d9b529b26..39e3aba90 100644
--- a/lib/wallet/wallet.ts
+++ b/lib/wallet/wallet.ts
@@ -239,6 +239,8 @@ interface Transaction {
export interface Badge {
setText(s: string): void;
setColor(c: string): void;
+ startBusy();
+ stopBusy();
}
@@ -348,6 +350,10 @@ export class Wallet {
private notifier: Notifier;
public cryptoApi: CryptoApi;
+ /**
+ * Set of identifiers for running operations.
+ */
+ private runningOperations: Set<string> = new Set();
constructor(db: IDBDatabase,
http: HttpRequestLibrary,
@@ -363,6 +369,18 @@ export class Wallet {
}
+ private startOperation(operationId: string) {
+ this.runningOperations.add(operationId);
+ this.badge.startBusy();
+ }
+
+ private stopOperation(operationId: string) {
+ this.runningOperations.delete(operationId);
+ if (this.runningOperations.size == 0) {
+ this.badge.stopBusy();
+ }
+ }
+
/**
* Resume various pending operations that are pending
* by looking at the database.
@@ -643,12 +661,15 @@ export class Wallet {
*/
private processReserve(reserveRecord): void {
let retryDelayMs = 100;
+ const opId = "reserve-" + reserveRecord.reserve_pub;
+ this.startOperation(opId);
this.updateExchangeFromUrl(reserveRecord.exchange_base_url)
.then((exchange) =>
this.updateReserve(reserveRecord.reserve_pub, exchange)
.then((reserve) => this.depleteReserve(reserve,
exchange)))
.then(() => {
+ this.stopOperation(opId);
let depleted = {
type: "depleted-reserve",
timestamp: (new Date).getTime(),
diff --git a/lib/wallet/wxMessaging.ts b/lib/wallet/wxMessaging.ts
index 164342f4e..522a87285 100644
--- a/lib/wallet/wxMessaging.ts
+++ b/lib/wallet/wxMessaging.ts
@@ -153,6 +153,14 @@ class ChromeBadge implements Badge {
setColor(c: string) {
chrome.browserAction.setBadgeBackgroundColor({color: c});
}
+
+ startBusy() {
+ this.setText("...");
+ }
+
+ stopBusy() {
+ this.setText("");
+ }
}