show progress
This commit is contained in:
parent
741dff2706
commit
ce7f7b8321
@ -239,6 +239,8 @@ interface Transaction {
|
|||||||
export interface Badge {
|
export interface Badge {
|
||||||
setText(s: string): void;
|
setText(s: string): void;
|
||||||
setColor(c: string): void;
|
setColor(c: string): void;
|
||||||
|
startBusy();
|
||||||
|
stopBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -348,6 +350,10 @@ export class Wallet {
|
|||||||
private notifier: Notifier;
|
private notifier: Notifier;
|
||||||
public cryptoApi: CryptoApi;
|
public cryptoApi: CryptoApi;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set of identifiers for running operations.
|
||||||
|
*/
|
||||||
|
private runningOperations: Set<string> = new Set();
|
||||||
|
|
||||||
constructor(db: IDBDatabase,
|
constructor(db: IDBDatabase,
|
||||||
http: HttpRequestLibrary,
|
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
|
* Resume various pending operations that are pending
|
||||||
* by looking at the database.
|
* by looking at the database.
|
||||||
@ -643,12 +661,15 @@ export class Wallet {
|
|||||||
*/
|
*/
|
||||||
private processReserve(reserveRecord): void {
|
private processReserve(reserveRecord): void {
|
||||||
let retryDelayMs = 100;
|
let retryDelayMs = 100;
|
||||||
|
const opId = "reserve-" + reserveRecord.reserve_pub;
|
||||||
|
this.startOperation(opId);
|
||||||
this.updateExchangeFromUrl(reserveRecord.exchange_base_url)
|
this.updateExchangeFromUrl(reserveRecord.exchange_base_url)
|
||||||
.then((exchange) =>
|
.then((exchange) =>
|
||||||
this.updateReserve(reserveRecord.reserve_pub, exchange)
|
this.updateReserve(reserveRecord.reserve_pub, exchange)
|
||||||
.then((reserve) => this.depleteReserve(reserve,
|
.then((reserve) => this.depleteReserve(reserve,
|
||||||
exchange)))
|
exchange)))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
this.stopOperation(opId);
|
||||||
let depleted = {
|
let depleted = {
|
||||||
type: "depleted-reserve",
|
type: "depleted-reserve",
|
||||||
timestamp: (new Date).getTime(),
|
timestamp: (new Date).getTime(),
|
||||||
|
@ -153,6 +153,14 @@ class ChromeBadge implements Badge {
|
|||||||
setColor(c: string) {
|
setColor(c: string) {
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color: c});
|
chrome.browserAction.setBadgeBackgroundColor({color: c});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
startBusy() {
|
||||||
|
this.setText("...");
|
||||||
|
}
|
||||||
|
|
||||||
|
stopBusy() {
|
||||||
|
this.setText("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user