on master help sign in
Make Actions page use usable invite count
32d8da9Fang
package.json+2−2
@@ -17,8 +17,8 @@
17 "@ledgerhq/hw-app-eth": "^4.35.0",
17 "@ledgerhq/hw-app-eth": "^4.35.0",
18 "@ledgerhq/hw-transport-u2f": "^4.35.0",
18 "@ledgerhq/hw-transport-u2f": "^4.35.0",
19 "PaperCollateralRenderer": "github:urbit/PaperCollateralRenderer",
19 "PaperCollateralRenderer": "github:urbit/PaperCollateralRenderer",
20− "azimuth-js": "^0.13.2",
20+ "azimuth-js": "^0.14.0",
21− "azimuth-solidity": "^1.1.0",
21+ "azimuth-solidity": "^1.2.0",
22 "babel-polyfill": "^6.26.0",
22 "babel-polyfill": "^6.26.0",
23 "bip32": "^1.0.2",
23 "bip32": "^1.0.2",
24 "bip39": "^2.5.0",
24 "bip39": "^2.5.0",
src/bridge/views/Point.js+5−16
@@ -18,7 +18,8 @@ class Point extends React.Component {
18 super(props)
18 super(props)
19
19
20 this.state = {
20 this.state = {
21− spawned: []
21+ spawned: [],
22+ invites: Nothing()
22 }
23 }
23 }
24 }
24
25
@@ -50,9 +51,8 @@ class Point extends React.Component {
50 pointCursor.chain(point => {
51 pointCursor.chain(point => {
51 azimuth.azimuth.getPoint(ctrcs, point)
52 azimuth.azimuth.getPoint(ctrcs, point)
52 .then(details => addToPointCache({ [point]: details }));
53 .then(details => addToPointCache({ [point]: details }));
53− const prefix = azimuth.azimuth.getPrefix(point);
54+ azimuth.delegatedSending.getTotalUsableInvites(ctrcs, point)
54− azimuth.azimuth.getPoint(ctrcs, prefix)
55+ .then(count => this.setState({ invites: Just(count) }));
55− .then(details => addToPointCache({ [prefix]: details }));
56 this.updateSpawned(ctrcs, point);
56 this.updateSpawned(ctrcs, point);
57 })));
57 })));
58 }
58 }
@@ -92,16 +92,6 @@ class Point extends React.Component {
92 ? Just(pointCache[point])
92 ? Just(pointCache[point])
93 : Nothing()
93 : Nothing()
94
94
95− const prefix = azimuth.azimuth.getPrefix(point);
96− const prefixDetails =
97− prefix in pointCache
98− ? Just(pointCache[prefix])
99− : Nothing();
100− const delegatedSending = contracts.matchWith({
101− Nothing: () => '0x',
102− Just: (c) => c.value.delegatedSending.address
103− })
104−
105 const name = ob.patp(point)
95 const name = ob.patp(point)
106
96
107 const sigil = pour({
97 const sigil = pour({
@@ -147,10 +137,9 @@ class Point extends React.Component {
147 pushRoute={ pushRoute }
137 pushRoute={ pushRoute }
148 online={ online }
138 online={ online }
149 wallet={ wallet }
139 wallet={ wallet }
150− delegatedSending={ delegatedSending }
151 point={ point }
140 point={ point }
152 pointDetails={ pointDetails }
141 pointDetails={ pointDetails }
153− prefixDetails={ prefixDetails } />
142+ invites={ this.state.invites } />
154 : null
143 : null
155 }
144 }
156
145
src/bridge/views/Point/Actions.js+16−10
@@ -19,7 +19,7 @@ const isStar = point =>
19const Actions = (props) => {
19const Actions = (props) => {
20 const {
20 const {
21 pushRoute, online, wallet, delegatedSending,
21 pushRoute, online, wallet, delegatedSending,
22− point, pointDetails, prefixDetails
22+ point, pointDetails, invites
23 } = props
23 } = props
24
24
25 const addr = wallet.matchWith({
25 const addr = wallet.matchWith({
@@ -64,10 +64,10 @@ const Actions = (props) => {
64 }
64 }
65 })
65 })
66
66
67− const prefixHasDelegatedSending =
67+ const hasInvites =
68− prefixDetails.matchWith({
68+ invites.matchWith({
69 Nothing: () => false,
69 Nothing: () => false,
70− Just: (details) => eqAddr(details.value.spawnProxy, delegatedSending)
70+ Just: (count) => (count.value > 0)
71 });
71 });
72
72
73 const planet = isPlanet(point)
73 const planet = isPlanet(point)
@@ -119,23 +119,29 @@ const Actions = (props) => {
119 }
119 }
120 })
120 })
121
121
122− let invites = null;
122+ let inviteAction = null;
123 if (planet) {
123 if (planet) {
124− invites = (
124+ inviteAction = (
125 <Button
125 <Button
126− disabled={(!isActiveOwner || !online || !prefixHasDelegatedSending)}
126+ disabled={(!isActiveOwner || !online || !hasInvites)}
127 prop-size={'sm'}
127 prop-size={'sm'}
128 prop-type={'link'}
128 prop-type={'link'}
129 onClick={ () => {
129 onClick={ () => {
130 pushRoute(ROUTE_NAMES.INVITES_SEND);
130 pushRoute(ROUTE_NAMES.INVITES_SEND);
131 }}
131 }}
132 >
132 >
133− { 'Send invites' }
133+ { 'Send invites (' }
134+ { invites.matchWith({
135+ Nothing: () => '?',
136+ Just: (count) => count.value
137+ })
138+ }
139+ { ')' }
134 </Button>
140 </Button>
135 );
141 );
136 }
142 }
137 if (star) {
143 if (star) {
138− invites = (
144+ inviteAction = (
139 <Button
145 <Button
140 disabled={(!(isActiveOwner && canIssueChild) || !online)}
146 disabled={(!(isActiveOwner && canIssueChild) || !online)}
141 prop-size={'sm'}
147 prop-size={'sm'}
@@ -254,7 +260,7 @@ const Actions = (props) => {
254 </Col>
260 </Col>
255 <Col className={'flex flex-column items-start col-md-4'}>
261 <Col className={'flex flex-column items-start col-md-4'}>
256
262
257− { invites }
263+ { inviteAction }
258
264
259 </Col>
265 </Col>
260 </Row>
266 </Row>