on master help sign in
store: improve point sync naming & performance
5eceb4efang
src/components/Passport.js+2−2
@@ -7,7 +7,7 @@ import 'style/anim.css';
7import * as need from 'lib/need';
7import * as need from 'lib/need';
8import { chunkStr, Matrix, walk, rand } from 'lib/card';
8import { chunkStr, Matrix, walk, rand } from 'lib/card';
9import usePermissionsForPoint from 'lib/usePermissionsForPoint';
9import usePermissionsForPoint from 'lib/usePermissionsForPoint';
10−import { useSyncOwnedPoints } from 'lib/useSyncPoints';
10+import { useSyncDetails } from 'lib/useSyncPoints';
11import { buildKeyType } from 'lib/point';
11import { buildKeyType } from 'lib/point';
12
12
13import { useWallet } from 'store/wallet';
13import { useWallet } from 'store/wallet';
@@ -212,7 +212,7 @@ const Cell = props => {
212 *
212 *
213 */
213 */
214function MiniPassport({ point, inverted, ...rest }) {
214function MiniPassport({ point, inverted, ...rest }) {
215− useSyncOwnedPoints([point]);
215+ useSyncDetails([point]);
216 const { wallet } = useWallet();
216 const { wallet } = useWallet();
217 const address = need.addressFromWallet(wallet);
217 const address = need.addressFromWallet(wallet);
218
218
src/lib/useSyncPoints.js+6−6
@@ -21,12 +21,12 @@ export const useSyncKnownPoints = buildSyncHook(function() {
21 return syncKnownPoint;
21 return syncKnownPoint;
22});
22});
23
23
24−export const useSyncForeignPoints = buildSyncHook(function() {
24+export const useSyncDetails = buildSyncHook(function() {
25− const { syncForeignPoint } = usePointCache();
25+ const { syncDetails } = usePointCache();
26− return syncForeignPoint;
26+ return syncDetails;
27});
27});
28
28
29−export const useSyncOwnedPoints = buildSyncHook(function() {
29+export const useSyncExtras = buildSyncHook(function() {
30− const { syncOwnedPoint } = usePointCache();
30+ const { syncExtras } = usePointCache();
31− return syncOwnedPoint;
31+ return syncExtras;
32});
32});
src/store/lib/usePointStore.js+4−21
@@ -20,38 +20,22 @@ export default function usePointStore() {
20 const { syncResidents, syncResidentCount, ...residents } = useResidents();
20 const { syncResidents, syncResidentCount, ...residents } = useResidents();
21 const ecliptic = useEclipticOwnerStore();
21 const ecliptic = useEclipticOwnerStore();
22
22
23− // sync all of the on-chain info required to display a known point
23+ //TODO more appropriately named "syncDates" or similar
24 const syncKnownPoint = useCallback(
24 const syncKnownPoint = useCallback(
25 async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
25 async point => Promise.all([syncBirthday(point), syncRekeyDate(point)]),
26 [syncBirthday, syncRekeyDate]
26 [syncBirthday, syncRekeyDate]
27 );
27 );
28
28
29− // sync all of the on-chain info required to display a foreign point
29+ const syncExtras = useCallback(
30− const syncForeignPoint = useCallback(
31− async point => {
32− syncDetails(point);
33− },
34− [syncDetails]
35− );
36−
37− // sync all of the on-chain info required for a point that the user owns
38− const syncOwnedPoint = useCallback(
39 async point =>
30 async point =>
40 Promise.all([
31 Promise.all([
41− syncForeignPoint(point),
42 syncKnownPoint(point),
32 syncKnownPoint(point),
43 //
33 //
44 syncResidentCount(point),
34 syncResidentCount(point),
45 syncDetails(point),
35 syncDetails(point),
46 syncInvites(point),
36 syncInvites(point),
47 ]),
37 ]),
48− [
49− syncForeignPoint,
50− syncKnownPoint,
51− syncDetails,
52− syncInvites,
53− syncResidentCount,
38+ [syncKnownPoint, syncDetails, syncInvites, syncResidentCount]
54− ]
55 );
39 );
56
40
57 return {
41 return {
@@ -67,8 +51,7 @@ export default function usePointStore() {
67 syncInvites,
51 syncInvites,
68 syncControlledPoints,
52 syncControlledPoints,
69 syncKnownPoint,
53 syncKnownPoint,
70− syncOwnedPoint,
71− syncForeignPoint,
72 syncResidents,
54 syncResidents,
55+ syncExtras,
73 };
56 };
74}
57}
src/views/Invite/Cohort.js+2−2
@@ -26,7 +26,7 @@ import Inviter from 'views/Invite/Inviter';
26
26
27import { ReactComponent as SearchIcon } from 'assets/search.svg';
27import { ReactComponent as SearchIcon } from 'assets/search.svg';
28import CopyButton from 'components/CopyButton';
28import CopyButton from 'components/CopyButton';
29−import { useSyncForeignPoints } from 'lib/useSyncPoints';
29+import { useSyncDetails } from 'lib/useSyncPoints';
30import { useNetwork } from 'store/network';
30import { useNetwork } from 'store/network';
31import NavHeader from 'components/NavHeader';
31import NavHeader from 'components/NavHeader';
32
32
@@ -305,7 +305,7 @@ export default function InviteCohort() {
305
305
306 const [selectedInvite, _setSelectedInvite] = useState();
306 const [selectedInvite, _setSelectedInvite] = useState();
307
307
308− useSyncForeignPoints([..._acceptedPoints, ..._pendingPoints]);
308+ useSyncDetails([..._acceptedPoints, ..._pendingPoints]);
309
309
310 const setSelectedInvite = useCallback(
310 const setSelectedInvite = useCallback(
311 p => _setSelectedInvite(old => (old === p ? null : p)),
311 p => _setSelectedInvite(old => (old === p ? null : p)),
src/views/Point.js+2−2
@@ -18,7 +18,7 @@ import { ForwardButton } from 'components/Buttons';
18
18
19import * as need from 'lib/need';
19import * as need from 'lib/need';
20import useInvites from 'lib/useInvites';
20import useInvites from 'lib/useInvites';
21−import { useSyncOwnedPoints } from 'lib/useSyncPoints';
21+import { useSyncExtras } from 'lib/useSyncPoints';
22import useCurrentPermissions from 'lib/useCurrentPermissions';
22import useCurrentPermissions from 'lib/useCurrentPermissions';
23import { useLocalRouter } from 'lib/LocalRouter';
23import { useLocalRouter } from 'lib/LocalRouter';
24
24
@@ -216,7 +216,7 @@ export default function Point() {
216 })();
216 })();
217
217
218 // sync the current cursor
218 // sync the current cursor
219− useSyncOwnedPoints([point]);
219+ useSyncExtras([point]);
220
220
221 const address = need.addressFromWallet(wallet);
221 const address = need.addressFromWallet(wallet);
222
222
src/views/Points.js−11
@@ -12,7 +12,6 @@ import { useStarReleaseCache } from 'store/starRelease';
12import * as need from 'lib/need';
12import * as need from 'lib/need';
13import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
13import { isZeroAddress, abbreviateAddress } from 'lib/wallet';
14import useIsEclipticOwner from 'lib/useIsEclipticOwner';
14import useIsEclipticOwner from 'lib/useIsEclipticOwner';
15−import { useSyncKnownPoints, useSyncOwnedPoints } from 'lib/useSyncPoints';
16import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
15import useRejectedIncomingPointTransfers from 'lib/useRejectedIncomingPointTransfers';
17import pluralize from 'lib/pluralize';
16import pluralize from 'lib/pluralize';
18import newGithubIssueUrl from 'new-github-issue-url';
17import newGithubIssueUrl from 'new-github-issue-url';
@@ -203,16 +202,6 @@ export default function Points() {
203 useEffect(() => {
202 useEffect(() => {
204 syncStarReleaseDetails();
203 syncStarReleaseDetails();
205 }, [syncStarReleaseDetails]);
204 }, [syncStarReleaseDetails]);
206− // sync display details for known points
207− useSyncKnownPoints([
208− ...ownedPoints,
209− ...incomingPoints,
210− ...managingPoints,
211− ...votingPoints,
212− ...spawningPoints,
213− ]);
214−
215− useSyncOwnedPoints(ownedPoints);
216
205
217 const goCreateGalaxy = useCallback(() => push(names.CREATE_GALAXY), [
206 const goCreateGalaxy = useCallback(() => push(names.CREATE_GALAXY), [
218 names.CREATE_GALAXY,
207 names.CREATE_GALAXY,
src/views/Release/Active.js+2−2
@@ -10,13 +10,13 @@ import { useWallet } from 'store/wallet';
10
10
11import * as need from 'lib/need';
11import * as need from 'lib/need';
12import usePermissionsForPoint from 'lib/usePermissionsForPoint';
12import usePermissionsForPoint from 'lib/usePermissionsForPoint';
13−import { useSyncOwnedPoints } from 'lib/useSyncPoints';
13+import { useSyncDetails } from 'lib/useSyncPoints';
14import { buildKeyType } from 'lib/point';
14import { buildKeyType } from 'lib/point';
15
15
16function ActiveViewRow({ point, goPoint }) {
16function ActiveViewRow({ point, goPoint }) {
17 const { wallet } = useWallet();
17 const { wallet } = useWallet();
18 const address = need.addressFromWallet(wallet);
18 const address = need.addressFromWallet(wallet);
19− useSyncOwnedPoints([point]);
19+ useSyncDetails([point]);
20 const permissions = usePermissionsForPoint(address, point);
20 const permissions = usePermissionsForPoint(address, point);
21
21
22 const keyType = buildKeyType(permissions);
22 const keyType = buildKeyType(permissions);