aboutsummaryrefslogtreecommitdiff
path: root/extension/lib
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-01-24 03:30:54 +0100
committerFlorian Dold <florian.dold@gmail.com>2016-01-24 03:30:54 +0100
commit53654b3622de38c6cca5d29f9969eb9a67caf8a0 (patch)
tree0f34658f03ef8489d10d5bcddc11c9b7a258895c /extension/lib
parentb8627813be56e04c18baf38885f3a3dc0fb7496c (diff)
Redirect to bank page on reserve creation success
Fixes #4084.
Diffstat (limited to 'extension/lib')
-rw-r--r--extension/lib/wallet/types.ts4
-rw-r--r--extension/lib/wallet/wallet.ts15
-rw-r--r--extension/lib/wallet/wxmessaging.js4
-rw-r--r--extension/lib/wallet/wxmessaging.ts5
4 files changed, 12 insertions, 16 deletions
diff --git a/extension/lib/wallet/types.ts b/extension/lib/wallet/types.ts
index 33de0ffb9..75233ff82 100644
--- a/extension/lib/wallet/types.ts
+++ b/extension/lib/wallet/types.ts
@@ -102,8 +102,6 @@ export interface ConfirmReserveRequest {
export interface ConfirmReserveResponse {
- backlink: string;
+ backlink?: string;
success: boolean;
- status: number;
- text: string;
} \ No newline at end of file
diff --git a/extension/lib/wallet/wallet.ts b/extension/lib/wallet/wallet.ts
index 2a931ae33..ab4c88da7 100644
--- a/extension/lib/wallet/wallet.ts
+++ b/extension/lib/wallet/wallet.ts
@@ -456,11 +456,16 @@ export class Wallet {
return this.http.postForm(req.post_url, form)
.then((hresp) => {
+ // TODO: look at response status code and handle errors appropriately
+ let json = JSON.parse(hresp.responseText);
+ if (!json) {
+ return {
+ success: false
+ };
+ }
let resp: ConfirmReserveResponse = {
- status: hresp.status,
- text: hresp.responseText,
success: undefined,
- backlink: undefined
+ backlink: json.redirect_url,
};
let reserveRecord = {
reserve_pub: reservePub.toCrock(),
@@ -488,9 +493,7 @@ export class Wallet {
};
resp.success = true;
- // We can't show the page directly, so
- // we show some generic page from the wallet.
- resp.backlink = null;
+
return Query(this.db)
.put("reserves", reserveRecord)
.put("history", historyEntry)
diff --git a/extension/lib/wallet/wxmessaging.js b/extension/lib/wallet/wxmessaging.js
index 93ffd8bb7..f54e0b35d 100644
--- a/extension/lib/wallet/wxmessaging.js
+++ b/extension/lib/wallet/wxmessaging.js
@@ -55,12 +55,10 @@ System.register(["./wallet", "./db", "./http"], function(exports_1) {
};
wallet.confirmReserve(req)
.then(function (resp) {
- if (resp.success) {
- resp.backlink = chrome.extension.getURL("pages/reserve-success.html");
- }
sendResponse(resp);
})
.catch(function (e) {
+ sendResponse({ success: false });
console.error("exception during 'confirm-reserve'");
console.error(e.stack);
});
diff --git a/extension/lib/wallet/wxmessaging.ts b/extension/lib/wallet/wxmessaging.ts
index de9d5907c..eb9f165db 100644
--- a/extension/lib/wallet/wxmessaging.ts
+++ b/extension/lib/wallet/wxmessaging.ts
@@ -72,13 +72,10 @@ function makeHandlers(wallet) {
};
wallet.confirmReserve(req)
.then((resp) => {
- if (resp.success) {
- resp.backlink = chrome.extension.getURL(
- "pages/reserve-success.html");
- }
sendResponse(resp);
})
.catch((e) => {
+ sendResponse({success: false});
console.error("exception during 'confirm-reserve'");
console.error(e.stack);
});