show progress
This commit is contained in:
parent
741dff2706
commit
ce7f7b8321
@ -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(),
|
||||
|
@ -153,6 +153,14 @@ class ChromeBadge implements Badge {
|
||||
setColor(c: string) {
|
||||
chrome.browserAction.setBadgeBackgroundColor({color: c});
|
||||
}
|
||||
|
||||
startBusy() {
|
||||
this.setText("...");
|
||||
}
|
||||
|
||||
stopBusy() {
|
||||
this.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user