on master help sign in
Merge pull request #946 from urbit/hm/small-fixes
ccc6b64tomholford
src/lib/useRoller.ts+15−3
@@ -92,6 +92,7 @@ export default function useRoller() {
92 const { setNextRoll } = useTimerStore();
92 const { setNextRoll } = useTimerStore();
93
93
94 const {
94 const {
95+ invitesLoading,
95 nextBatchTime,
96 nextBatchTime,
96 point,
97 point,
97 points,
98 points,
@@ -262,7 +263,8 @@ export default function useRoller() {
262 }: UpdateParams) => {
263 }: UpdateParams) => {
263 if (l1Txn) storePendingL1Txn(l1Txn);
264 if (l1Txn) storePendingL1Txn(l1Txn);
264
265
265− const interval = setInterval(async () => {
266+ let interval: any;
267+ const check = async () => {
266 const updatedPoint = await initPoint(point);
268 const updatedPoint = await initPoint(point);
267 const changedField = !points[point]
269 const changedField = !points[point]
268 ? 'newPoint'
270 ? 'newPoint'
@@ -274,7 +276,10 @@ export default function useRoller() {
274
276
275 if (!updatedPoint.isPlaceholder && changedField) {
277 if (!updatedPoint.isPlaceholder && changedField) {
276 updatePoint(updatedPoint);
278 updatePoint(updatedPoint);
279+ if (interval) {
277− clearInterval(interval);
280+ clearInterval(interval);
281+ }
282+
278 if (l1Txn) deletePendingL1Txn(l1Txn);
283 if (l1Txn) deletePendingL1Txn(l1Txn);
279 if (notify) {
284 if (notify) {
280 showNotification(
285 showNotification(
@@ -282,7 +287,10 @@ export default function useRoller() {
282 );
287 );
283 }
288 }
284 }
289 }
290+ };
291+
285− }, intervalTime);
292+ interval = setInterval(check, intervalTime);
293+ check();
286 },
294 },
287 [points, initPoint, updatePoint, storePendingL1Txn, deletePendingL1Txn]
295 [points, initPoint, updatePoint, storePendingL1Txn, deletePendingL1Txn]
288 );
296 );
@@ -352,6 +360,10 @@ export default function useRoller() {
352 };
360 };
353
361
354 const getInvites = useCallback(async () => {
362 const getInvites = useCallback(async () => {
363+ if (invitesLoading) {
364+ return;
365+ }
366+
355 try {
367 try {
356 setInvitesLoading(true);
368 setInvitesLoading(true);
357 const curPoint: number = Number(need.point(pointCursor));
369 const curPoint: number = Number(need.point(pointCursor));
src/views/AcceptTransfer.tsx+13−1
@@ -1,4 +1,10 @@
1−import React, { useCallback, useEffect, useMemo, useState } from 'react';
1+import React, {
2+ useCallback,
3+ useEffect,
4+ useMemo,
5+ useRef,
6+ useState,
7+} from 'react';
2import cn from 'classnames';
8import cn from 'classnames';
3import { Nothing } from 'folktale/maybe';
9import { Nothing } from 'folktale/maybe';
4import { Grid, Text, CheckboxInput, Button } from 'indigo-react';
10import { Grid, Text, CheckboxInput, Button } from 'indigo-react';
@@ -68,6 +74,7 @@ export default function AcceptTransfer() {
68
74
69 const name = useCurrentPointName();
75 const name = useCurrentPointName();
70
76
77+ const transferring = useRef(false);
71 const [reset, setReset] = useState(true);
78 const [reset, setReset] = useState(true);
72
79
73 const {
80 const {
@@ -115,6 +122,11 @@ export default function AcceptTransfer() {
115 }, [pop, setPointCursor]);
122 }, [pop, setPointCursor]);
116
123
117 const acceptTransfer = useCallback(async () => {
124 const acceptTransfer = useCallback(async () => {
125+ if (transferring.current) {
126+ return;
127+ }
128+
129+ transferring.current = true;
118 await transferPoint(_address, reset);
130 await transferPoint(_address, reset);
119 await checkForUpdates({
131 await checkForUpdates({
120 point: point.value,
132 point: point.value,
src/views/Points.tsx+10−1
@@ -121,7 +121,16 @@ export default function Points() {
121 [getDetails, controlledPoints, _contracts]
121 [getDetails, controlledPoints, _contracts]
122 );
122 );
123
123
124+ const allPoints = useMemo(
125+ () =>
124− const allPoints = pointList.filter(({ shouldDisplay }) => shouldDisplay);
126+ pointList.filter(
127+ ({ isTransferProxy, isTransferProxySet, shouldDisplay, value }) =>
128+ shouldDisplay &&
129+ !(isTransferProxy || isTransferProxySet) &&
130+ !rejectedPoints.includes(value)
131+ ),
132+ [pointList, rejectedPoints]
133+ );
125
134
126 // if we can only interact with a single point, jump to the point page.
135 // if we can only interact with a single point, jump to the point page.
127 // if there are any pending transfers, incoming or outgoing, stay on this
136 // if there are any pending transfers, incoming or outgoing, stay on this