manual refresh triggering

This commit is contained in:
Florian Dold 2016-10-13 02:36:33 +02:00
parent 250069d860
commit e4cafe672d
5 changed files with 25 additions and 5 deletions

View File

@ -1136,8 +1136,12 @@ export class Wallet {
coin.currentAmount,
oldDenom.fee_refresh));
// FIXME: implement rest
let reqUrl = URI("reserve/withdraw").absoluteTo(exchange!.baseUrl);
let resp = await this.http.postJson(reqUrl, {});
console.log("melt response:", resp.responseText);
// FIXME: implement rest
}

View File

@ -69,3 +69,7 @@ export async function getCoins(exchangeBaseUrl: string): Promise<Coin[]> {
export async function getPreCoins(exchangeBaseUrl: string): Promise<PreCoin[]> {
return await callBackend("get-precoins", { exchangeBaseUrl });
}
export async function refresh(coinPub: string): Promise<void> {
return await callBackend("refresh-coin", { coinPub });
}

View File

@ -204,6 +204,12 @@ function makeHandlers(db: IDBDatabase,
}
return wallet.getPreCoins(detail.exchangeBaseUrl);
},
["refresh-coin"]: function (detail, sender) {
if (typeof detail.coinPub !== "string") {
return Promise.reject(Error("coinPub missing"));
}
return wallet.refresh(detail.coinPub);
},
["payment-failed"]: function (detail, sender) {
// For now we just update exchanges (maybe the exchange did something
// wrong and the keys were messed up).

View File

@ -25,7 +25,10 @@
import { IExchangeInfo } from "../lib/wallet/types";
import { ReserveRecord, Coin, PreCoin, Denomination } from "../lib/wallet/types";
import { ImplicitStateComponent, StateHolder } from "../lib/components";
import { getReserves, getExchanges, getCoins, getPreCoins } from "../lib/wallet/wxApi";
import {
getReserves, getExchanges, getCoins, getPreCoins,
refresh
} from "../lib/wallet/wxApi";
import { prettyAmount, abbrev } from "../lib/wallet/renderHtml";
interface ReserveViewProps {
@ -101,7 +104,7 @@ class RefreshDialog extends ImplicitStateComponent<RefreshDialogProps> {
return (
<div>
Refresh amount: <input type="text" size={10} />
<button>ok</button>
<button onClick={() => refresh(this.props.coin.coinPub)}>ok</button>
<button onClick={() => this.refreshRequested(false)}>cancel</button>
</div>
);

View File

@ -52,9 +52,9 @@ class Router extends preact.Component<any,any> {
}
static onRoute(f: any): () => void {
this.routeHandlers.push(f);
Router.routeHandlers.push(f);
return () => {
let i = this.routeHandlers.indexOf(f);
let i = Router.routeHandlers.indexOf(f);
this.routeHandlers = this.routeHandlers.splice(i, 1);
}
}
@ -391,6 +391,9 @@ function WalletDebug(props: any) {
<button onClick={openExtensionPage("pages/show-db.html")}>
show db
</button>
<button onClick={openExtensionPage("pages/tree.html")}>
show tree
</button>
<br />
<button onClick={confirmReset}>
reset