diff options
Diffstat (limited to 'lib/wallet')
-rw-r--r-- | lib/wallet/wallet.ts | 21 | ||||
-rw-r--r-- | lib/wallet/wxMessaging.ts | 8 |
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(""); + } } |