on master help sign in
Make Actions page use usable invite count
commit32d8da95c461676fbdfad4059cd8e91d55ae30f9 authorFang <git@fang.io> dateTue 4 Jun 2019, 15:59 (7 years ago) parentcc050b6
3 files changed+23−28
package.json+2−2 src/bridge/views/Point.js+5−16 src/bridge/views/Point/Actions.js+16−10
package.json+2−2
@@ -17,8 +17,8 @@
1717 "@ledgerhq/hw-app-eth": "^4.35.0",
1818 "@ledgerhq/hw-transport-u2f": "^4.35.0",
1919 "PaperCollateralRenderer": "github:urbit/PaperCollateralRenderer",
20− "azimuth-js": "^0.13.2",
21− "azimuth-solidity": "^1.1.0",
20+ "azimuth-js": "^0.14.0",
21+ "azimuth-solidity": "^1.2.0",
2222 "babel-polyfill": "^6.26.0",
2323 "bip32": "^1.0.2",
2424 "bip39": "^2.5.0",
src/bridge/views/Point.js+5−16
@@ -18,7 +18,8 @@ class Point extends React.Component {
1818 super(props)
1919
2020 this.state = {
21− spawned: []
21+ spawned: [],
22+ invites: Nothing()
2223 }
2324 }
2425
@@ -50,9 +51,8 @@ class Point extends React.Component {
5051 pointCursor.chain(point => {
5152 azimuth.azimuth.getPoint(ctrcs, point)
5253 .then(details => addToPointCache({ [point]: details }));
53− const prefix = azimuth.azimuth.getPrefix(point);
54− azimuth.azimuth.getPoint(ctrcs, prefix)
55− .then(details => addToPointCache({ [prefix]: details }));
54+ azimuth.delegatedSending.getTotalUsableInvites(ctrcs, point)
55+ .then(count => this.setState({ invites: Just(count) }));
5656 this.updateSpawned(ctrcs, point);
5757 })));
5858 }
@@ -92,16 +92,6 @@ class Point extends React.Component {
9292 ? Just(pointCache[point])
9393 : Nothing()
9494
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−
10595 const name = ob.patp(point)
10696
10797 const sigil = pour({
@@ -147,10 +137,9 @@ class Point extends React.Component {
147137 pushRoute={ pushRoute }
148138 online={ online }
149139 wallet={ wallet }
150− delegatedSending={ delegatedSending }
151140 point={ point }
152141 pointDetails={ pointDetails }
153− prefixDetails={ prefixDetails } />
142+ invites={ this.state.invites } />
154143 : null
155144 }
156145
src/bridge/views/Point/Actions.js+16−10
@@ -19,7 +19,7 @@ const isStar = point =>
1919const Actions = (props) => {
2020 const {
2121 pushRoute, online, wallet, delegatedSending,
22− point, pointDetails, prefixDetails
22+ point, pointDetails, invites
2323 } = props
2424
2525 const addr = wallet.matchWith({
@@ -64,10 +64,10 @@ const Actions = (props) => {
6464 }
6565 })
6666
67− const prefixHasDelegatedSending =
68− prefixDetails.matchWith({
67+ const hasInvites =
68+ invites.matchWith({
6969 Nothing: () => false,
70− Just: (details) => eqAddr(details.value.spawnProxy, delegatedSending)
70+ Just: (count) => (count.value > 0)
7171 });
7272
7373 const planet = isPlanet(point)
@@ -119,23 +119,29 @@ const Actions = (props) => {
119119 }
120120 })
121121
122− let invites = null;
122+ let inviteAction = null;
123123 if (planet) {
124− invites = (
124+ inviteAction = (
125125 <Button
126− disabled={(!isActiveOwner || !online || !prefixHasDelegatedSending)}
126+ disabled={(!isActiveOwner || !online || !hasInvites)}
127127 prop-size={'sm'}
128128 prop-type={'link'}
129129 onClick={ () => {
130130 pushRoute(ROUTE_NAMES.INVITES_SEND);
131131 }}
132132 >
133− { 'Send invites' }
133+ { 'Send invites (' }
134+ { invites.matchWith({
135+ Nothing: () => '?',
136+ Just: (count) => count.value
137+ })
138+ }
139+ { ')' }
134140 </Button>
135141 );
136142 }
137143 if (star) {
138− invites = (
144+ inviteAction = (
139145 <Button
140146 disabled={(!(isActiveOwner && canIssueChild) || !online)}
141147 prop-size={'sm'}
@@ -254,7 +260,7 @@ const Actions = (props) => {
254260 </Col>
255261 <Col className={'flex flex-column items-start col-md-4'}>
256262
257− { invites }
263+ { inviteAction }
258264
259265 </Col>
260266 </Row>