on master help sign in
Don't rely on props being updated during pointCursor deduction
a14d3fbFang
src/bridge/views/Login.js+8−3
@@ -64,27 +64,32 @@ class Login extends React.Component {
64 const contracts = need.contracts(this.props);
64 const contracts = need.contracts(this.props);
65
65
66 // if no point cursor set by login logic, try to deduce it
66 // if no point cursor set by login logic, try to deduce it
67+ let deduced = Nothing();
67 if (Nothing.hasInstance(this.props.pointCursor)) {
68 if (Nothing.hasInstance(this.props.pointCursor)) {
68 const owned = await azimuth.azimuth.getOwnedPoints(
69 const owned = await azimuth.azimuth.getOwnedPoints(
69 contracts,
70 contracts,
70 wallet.address
71 wallet.address
71 );
72 );
72 if (owned.length === 1) {
73 if (owned.length === 1) {
73− this.props.setPointCursor(Just(owned[0]));
74+ deduced = Just(owned[0]);
74 } else if (owned.length === 0) {
75 } else if (owned.length === 0) {
75 const canOwn = await azimuth.azimuth.getTransferringFor(
76 const canOwn = await azimuth.azimuth.getTransferringFor(
76 contracts,
77 contracts,
77 wallet.address
78 wallet.address
78 );
79 );
79 if (canOwn.length === 1) {
80 if (canOwn.length === 1) {
80− this.props.setPointCursor(Just(canOwn[0]));
81+ deduced = Just(canOwn[0]);
81 }
82 }
82 }
83 }
83 }
84 }
84
85
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)) {
86 this.props.history.popAndPush(ROUTE_NAMES.POINT_HOME);
90 this.props.history.popAndPush(ROUTE_NAMES.POINT_HOME);
87 } else {
91 } else {
92+ //TODO to new overview (maybe should be merged into point home?)
88 this.props.history.popAndPush(ROUTE_NAMES.SHIPS);
93 this.props.history.popAndPush(ROUTE_NAMES.SHIPS);
89 }
94 }
90 }
95 }