on master help sign in
points: show error message if we failed chain read
067deb9fang
src/store/lib/useControlledPointsStore.js+23−11
@@ -37,17 +37,29 @@ export default function useControlledPointsStore() {
37 azimuth.azimuth.getSpawningFor(_contracts, address),
37 azimuth.azimuth.getSpawningFor(_contracts, address),
38 ]);
38 ]);
39
39
40+ if (
41+ ownedPoints === null &&
42+ incomingPoints === null &&
43+ managingPoints === null &&
44+ votingPoints === null &&
45+ spawningPoints === null
46+ ) {
40− _setControlledPoints(
47+ _setControlledPoints(
41− Just(
48+ Just(Result.Error('Failed to read the blockchain.'))
49+ );
50+ } else {
51+ _setControlledPoints(
52+ Just(
42− Result.Ok({
53+ Result.Ok({
43− ownedPoints,
54+ ownedPoints,
44− incomingPoints,
55+ incomingPoints,
45− managingPoints,
56+ managingPoints,
46− votingPoints,
57+ votingPoints,
47− spawningPoints,
58+ spawningPoints,
48− })
59+ })
49− )
60+ )
50− );
61+ );
62+ }
51 } catch (error) {
63 } catch (error) {
52 _setControlledPoints(Just(Result.Error(error)));
64 _setControlledPoints(Just(Result.Error(error)));
53 }
65 }
src/views/Points.js+32−1
@@ -1,5 +1,5 @@
1import React, { useCallback, useEffect, useMemo } from 'react';
1import React, { useCallback, useEffect, useMemo } from 'react';
2−import { Just, Nothing } from 'folktale/maybe';
2+import { Just, Nothing, Result } from 'folktale/maybe';
3import { Grid, H5, HelpText, LinkButton, Flex } from 'indigo-react';
3import { Grid, H5, HelpText, LinkButton, Flex } from 'indigo-react';
4import { get } from 'lodash';
4import { get } from 'lodash';
5
5
@@ -15,6 +15,7 @@ import useIsEclipticOwner from 'lib/useIsEclipticOwner';
15import { useSyncKnownPoints, useSyncOwnedPoints } from 'lib/useSyncPoints';
15import { useSyncKnownPoints, useSyncOwnedPoints } from 'lib/useSyncPoints';
16import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
16import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
17import pluralize from 'lib/pluralize';
17import pluralize from 'lib/pluralize';
18+import newGithubIssueUrl from 'new-github-issue-url';
18
19
19import View from 'components/View';
20import View from 'components/View';
20import Blinky from 'components/Blinky';
21import Blinky from 'components/Blinky';
@@ -223,6 +224,36 @@ export default function Points() {
223 push,
224 push,
224 ]);
225 ]);
225
226
227+ // if we got an error result, we should display it, instead of showing
228+ // a potentially inaccurately empty point list.
229+ //
230+ if (
231+ Just.hasInstance(controlledPoints) &&
232+ controlledPoints.value.matchWith({
233+ Error: e => true,
234+ Ok: v => false,
235+ })
236+ ) {
237+ const url = newGithubIssueUrl({
238+ user: 'urbit',
239+ repo: 'bridge',
240+ title: controlledPoints.value.value,
241+ body: `<!-- Please provide some context. Do you have Metamask installed? What login method did you use? -->`,
242+ });
243+ return (
244+ <View inset>
245+ <Grid>
246+ <Grid.Item full as={HelpText} className="mt8 t-center">
247+ {controlledPoints.value.value}
248+ <br />
249+ Try reloading the page. If this problem persists, please{' '}
250+ <a href={url}>file an issue on GitHub</a>.
251+ </Grid.Item>
252+ </Grid>
253+ </View>
254+ );
255+ }
256+
226 if (
257 if (
227 loading ||
258 loading ||
228 (allPoints.length === 1 &&
259 (allPoints.length === 1 &&