on master help sign in
Only enable admin page when usable
commita9887cf7acf0117b35de81dd705d53677081ea82 authorFang <git@fang.io> dateFri 5 Jul 2019, 12:31 (7 years ago) parentcc52956
1 file changed+17−2
src/views/Point.js+17−2
src/views/Point.js+17−2
@@ -16,6 +16,7 @@ import { matchBlinky } from 'components/Blinky';
1616import useInvites from 'lib/useInvites';
1717import { useSyncOwnedPoints } from 'lib/useSyncPoints';
1818import { ROUTE_NAMES } from 'lib/routeNames';
19+import { eqAddr } from 'lib/wallet';
1920
2021import Actions from './Point/Actions';
2122import { useWallet } from 'store/wallet';
@@ -27,7 +28,21 @@ export default function Point() {
2728 const { wallet } = useWallet();
2829
2930 const point = need.point(pointCursor);
30− const hasInCache = point in pointCache;
31+
32+ let canAdmin = false;
33+ if (point in pointCache) {
34+ canAdmin = wallet.matchWith({
35+ Nothing: () => false,
36+ Just: wal => {
37+ const pointDetails = need.fromPointCache(pointCache, point);
38+ const address = need.addressFromWallet(wallet);
39+ return (
40+ eqAddr(address, pointDetails.owner) ||
41+ eqAddr(address, pointDetails.managementProxy)
42+ );
43+ },
44+ });
45+ }
3146
3247 // fetch the invites for the current cursor
3348 const { availableInvites } = useInvites(point);
@@ -51,7 +66,7 @@ export default function Point() {
5166 <Grid.Item
5267 full
5368 as={ForwardButton}
54− disabled={!hasInCache}
69+ disabled={!canAdmin}
5570 onClick={goAdmin}>
5671 Admin
5772 </Grid.Item>