From 24181bdf20e0d23ec5ec5d2eaa08ae1cfb905f0f Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Sun, 27 Aug 2017 04:19:11 +0200
Subject: better error report / retry prompt for failed payments

---
 src/webex/pages/confirm-create-reserve.tsx | 36 +-----------------------------
 1 file changed, 1 insertion(+), 35 deletions(-)

(limited to 'src/webex/pages/confirm-create-reserve.tsx')

diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx
index 4e3b6748f..f957364c4 100644
--- a/src/webex/pages/confirm-create-reserve.tsx
+++ b/src/webex/pages/confirm-create-reserve.tsx
@@ -41,7 +41,7 @@ import {
   getReserveCreationInfo,
 } from "../wxApi";
 
-import {renderAmount} from "../renderHtml";
+import {Collapsible, renderAmount} from "../renderHtml";
 
 import * as React from "react";
 import * as ReactDOM from "react-dom";
@@ -80,40 +80,6 @@ class EventTrigger {
 }
 
 
-interface CollapsibleState {
-  collapsed: boolean;
-}
-
-interface CollapsibleProps {
-  initiallyCollapsed: boolean;
-  title: string;
-}
-
-class Collapsible extends React.Component<CollapsibleProps, CollapsibleState> {
-  constructor(props: CollapsibleProps) {
-    super(props);
-    this.state = { collapsed: props.initiallyCollapsed };
-  }
-  render() {
-    const doOpen = (e: any) => {
-      this.setState({collapsed: false});
-      e.preventDefault();
-    };
-    const doClose = (e: any) => {
-      this.setState({collapsed: true});
-      e.preventDefault();
-    };
-    if (this.state.collapsed) {
-      return <h2><a className="opener opener-collapsed" href="#" onClick={doOpen}>{this.props.title}</a></h2>;
-    }
-    return (
-      <div>
-        <h2><a className="opener opener-open" href="#" onClick={doClose}>{this.props.title}</a></h2>
-        {this.props.children}
-      </div>
-    );
-  }
-}
 
 function renderAuditorDetails(rci: ReserveCreationInfo|null) {
   console.log("rci", rci);
-- 
cgit v1.2.3


From 43575b591921e994761fd531bcfe95239119b695 Mon Sep 17 00:00:00 2001
From: Florian Dold <florian.dold@gmail.com>
Date: Sun, 27 Aug 2017 06:47:13 +0200
Subject: show error in create reserve dialog

---
 src/webex/pages/confirm-create-reserve.tsx | 11 ++++-------
 src/webex/wxBackend.ts                     |  2 +-
 2 files changed, 5 insertions(+), 8 deletions(-)

(limited to 'src/webex/pages/confirm-create-reserve.tsx')

diff --git a/src/webex/pages/confirm-create-reserve.tsx b/src/webex/pages/confirm-create-reserve.tsx
index f957364c4..7d543860f 100644
--- a/src/webex/pages/confirm-create-reserve.tsx
+++ b/src/webex/pages/confirm-create-reserve.tsx
@@ -371,7 +371,7 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
     if (this.statusString()) {
       return (
         <p>
-          <strong style={{color: "red"}}>{i18n.str`A problem occured, see below. ${this.statusString()}`}</strong>
+          <strong style={{color: "red"}}>{this.statusString()}</strong>
         </p>
       );
     }
@@ -515,12 +515,9 @@ class ExchangeSelection extends ImplicitStateComponent<ExchangeSelectionProps> {
       console.dir(r);
     } catch (e) {
       console.log("get exchange info rejected", e);
-      if (e.hasOwnProperty("httpStatus")) {
-        this.statusString(`Error: request failed with status ${e.httpStatus}`);
-      } else if (e.hasOwnProperty("errorResponse")) {
-        const resp = e.errorResponse;
-        this.statusString(`Error: ${resp.error} (${resp.hint})`);
-      }
+      this.statusString(`Error: ${e.message}`);
+      // Re-try every 5 seconds as long as there is a problem
+      setTimeout(() => this.statusString() ? this.forceReserveUpdate() : undefined, 5000);
     }
   }
 
diff --git a/src/webex/wxBackend.ts b/src/webex/wxBackend.ts
index 0d1c2d8ca..2f249af44 100644
--- a/src/webex/wxBackend.ts
+++ b/src/webex/wxBackend.ts
@@ -352,7 +352,7 @@ async function dispatch(req: any, sender: any, sendResponse: any): Promise<void>
     try {
       sendResponse({
         error: "exception",
-        hint: e.message,
+        message: e.message,
         stack,
       });
     } catch (e) {
-- 
cgit v1.2.3

