on master help sign in
Don't rely on props being updated during pointCursor deduction
commita14d3fbbba5151496c3e1c7a352e5d9108b7b2e0 authorFang <git@fang.io> dateWed 19 Jun 2019, 19:56 (7 years ago) parent41f9889
1 file changed+8−3
src/bridge/views/Login.js+8−3
src/bridge/views/Login.js+8−3
@@ -64,27 +64,32 @@ class Login extends React.Component {
6464 const contracts = need.contracts(this.props);
6565
6666 // if no point cursor set by login logic, try to deduce it
67+ let deduced = Nothing();
6768 if (Nothing.hasInstance(this.props.pointCursor)) {
6869 const owned = await azimuth.azimuth.getOwnedPoints(
6970 contracts,
7071 wallet.address
7172 );
7273 if (owned.length === 1) {
73− this.props.setPointCursor(Just(owned[0]));
74+ deduced = Just(owned[0]);
7475 } else if (owned.length === 0) {
7576 const canOwn = await azimuth.azimuth.getTransferringFor(
7677 contracts,
7778 wallet.address
7879 );
7980 if (canOwn.length === 1) {
80− this.props.setPointCursor(Just(canOwn[0]));
81+ deduced = Just(canOwn[0]);
8182 }
8283 }
8384 }
8485
85− if (Just.hasInstance(this.props.pointCursor)) {
86+ if (Just.hasInstance(deduced)) {
87+ this.props.setPointCursor(deduced);
88+ this.props.history.popAndPush(ROUTE_NAMES.POINT_HOME);
89+ } else if (Just.hasInstance(this.props.pointCursor)) {
8690 this.props.history.popAndPush(ROUTE_NAMES.POINT_HOME);
8791 } else {
92+ //TODO to new overview (maybe should be merged into point home?)
8893 this.props.history.popAndPush(ROUTE_NAMES.SHIPS);
8994 }
9095 }