on master help sign in
Disable "send invites" action when prefix not participating
commit4ef142d0f2869d12d60d761685ea862a60323c42 authorFang <git@fang.io> dateFri 26 Apr 2019, 01:44 (8 years ago) parent7029bf4
2 files changed+39−9
src/bridge/views/Point.js+28−7 src/bridge/views/Point/Actions.js+11−2
src/bridge/views/Point.js+28−7
@@ -49,9 +49,12 @@ class Point extends React.Component {
4949 contracts.chain(ctrcs =>
5050 pointCursor.chain(point => {
5151 azimuth.azimuth.getPoint(ctrcs, point)
52− .then(details => addToPointCache({ [point]: details }))
53− this.updateSpawned(ctrcs, point)
54− })))
52+ .then(details => addToPointCache({ [point]: details }));
53+ const prefix = azimuth.azimuth.getPrefix(point);
54+ azimuth.azimuth.getPoint(ctrcs, point)
55+ .then(details => addToPointCache({ [prefix]: details }));
56+ this.updateSpawned(ctrcs, point);
57+ })));
5558 }
5659
5760 updateSpawned = contracts => {
@@ -69,9 +72,10 @@ class Point extends React.Component {
6972
7073 render() {
7174
72− const { web3, popRoute, pushRoute, wallet } = this.props
73− const { setPointCursor } = this.props
74− const { pointCursor, pointCache } = this.props
75+ const {
76+ web3, popRoute, pushRoute, wallet, contracts,
77+ setPointCursor, pointCursor, pointCache
78+ } = this.props;
7579
7680 const { spawned } = this.state
7781
@@ -88,6 +92,16 @@ class Point extends React.Component {
8892 ? Just(pointCache[point])
8993 : Nothing()
9094
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+
91105 const name = ob.patp(point)
92106
93107 const sigil = pour({
@@ -129,7 +143,14 @@ class Point extends React.Component {
129143 <H1><code>{ name }</code></H1>
130144 {
131145 authenticated
132− ? <Actions pushRoute={ pushRoute } online={ online } point={ point } pointDetails={ pointDetails } wallet={ wallet }/>
146+ ? <Actions
147+ pushRoute={ pushRoute }
148+ online={ online }
149+ wallet={ wallet }
150+ delegatedSending={ delegatedSending }
151+ point={ point }
152+ pointDetails={ pointDetails }
153+ prefixDetails={ prefixDetails } />
133154 : null
134155 }
135156
src/bridge/views/Point/Actions.js+11−2
@@ -17,7 +17,10 @@ const isStar = point =>
1717 (azimuth.getPointSize(point) === azimuth.PointSize.Star);
1818
1919const Actions = (props) => {
20− const { pushRoute, online, point, pointDetails, wallet } = props
20+ const {
21+ pushRoute, online, wallet, delegatedSending,
22+ point, pointDetails, prefixDetails
23+ } = props
2124
2225 const addr = wallet.matchWith({
2326 Just: (wal) => addressFromSecp256k1Public(wal.value.publicKey),
@@ -61,6 +64,12 @@ const Actions = (props) => {
6164 }
6265 })
6366
67+ const prefixHasDelegatedSending =
68+ prefixDetails.matchWith({
69+ Nothing: () => false,
70+ Just: (details) => eqAddr(details.value.spawnProxy, delegatedSending)
71+ });
72+
6473 const planet = isPlanet(point)
6574 const star = isStar(point)
6675
@@ -114,7 +123,7 @@ const Actions = (props) => {
114123 if (planet) {
115124 invites = (
116125 <Button
117− disabled={(!isActiveOwner || !online)}
126+ disabled={(!isActiveOwner || !online || !prefixHasDelegatedSending)}
118127 prop-size={'sm'}
119128 prop-type={'link'}
120129 onClick={ () => {