on master help sign in
Merge pull request #946 from urbit/hm/small-fixes

Fix grab-bag

commitccc6b64ab8b67bd8e699a886bd0c7c40ad8cf0f8 authortomholford <16504501+tomholford@users.noreply.github.com> dateTue 8 Feb 2022, 20:33 (5 years ago) parent3652e4450d585b
3 files changed+38−5
src/lib/useRoller.ts+15−3 src/views/AcceptTransfer.tsx+13−1 src/views/Points.tsx+10−1
src/lib/useRoller.ts+15−3
@@ -92,6 +92,7 @@ export default function useRoller() {
9292 const { setNextRoll } = useTimerStore();
9393
9494 const {
95+ invitesLoading,
9596 nextBatchTime,
9697 point,
9798 points,
@@ -262,7 +263,8 @@ export default function useRoller() {
262263 }: UpdateParams) => {
263264 if (l1Txn) storePendingL1Txn(l1Txn);
264265
265− const interval = setInterval(async () => {
266+ let interval: any;
267+ const check = async () => {
266268 const updatedPoint = await initPoint(point);
267269 const changedField = !points[point]
268270 ? 'newPoint'
@@ -274,7 +276,10 @@ export default function useRoller() {
274276
275277 if (!updatedPoint.isPlaceholder && changedField) {
276278 updatePoint(updatedPoint);
277− clearInterval(interval);
279+ if (interval) {
280+ clearInterval(interval);
281+ }
282+
278283 if (l1Txn) deletePendingL1Txn(l1Txn);
279284 if (notify) {
280285 showNotification(
@@ -282,7 +287,10 @@ export default function useRoller() {
282287 );
283288 }
284289 }
285− }, intervalTime);
290+ };
291+
292+ interval = setInterval(check, intervalTime);
293+ check();
286294 },
287295 [points, initPoint, updatePoint, storePendingL1Txn, deletePendingL1Txn]
288296 );
@@ -352,6 +360,10 @@ export default function useRoller() {
352360 };
353361
354362 const getInvites = useCallback(async () => {
363+ if (invitesLoading) {
364+ return;
365+ }
366+
355367 try {
356368 setInvitesLoading(true);
357369 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';
28import cn from 'classnames';
39import { Nothing } from 'folktale/maybe';
410import { Grid, Text, CheckboxInput, Button } from 'indigo-react';
@@ -68,6 +74,7 @@ export default function AcceptTransfer() {
6874
6975 const name = useCurrentPointName();
7076
77+ const transferring = useRef(false);
7178 const [reset, setReset] = useState(true);
7279
7380 const {
@@ -115,6 +122,11 @@ export default function AcceptTransfer() {
115122 }, [pop, setPointCursor]);
116123
117124 const acceptTransfer = useCallback(async () => {
125+ if (transferring.current) {
126+ return;
127+ }
128+
129+ transferring.current = true;
118130 await transferPoint(_address, reset);
119131 await checkForUpdates({
120132 point: point.value,
src/views/Points.tsx+10−1
@@ -121,7 +121,16 @@ export default function Points() {
121121 [getDetails, controlledPoints, _contracts]
122122 );
123123
124− const allPoints = pointList.filter(({ shouldDisplay }) => shouldDisplay);
124+ const allPoints = useMemo(
125+ () =>
126+ pointList.filter(
127+ ({ isTransferProxy, isTransferProxySet, shouldDisplay, value }) =>
128+ shouldDisplay &&
129+ !(isTransferProxy || isTransferProxySet) &&
130+ !rejectedPoints.includes(value)
131+ ),
132+ [pointList, rejectedPoints]
133+ );
125134
126135 // if we can only interact with a single point, jump to the point page.
127136 // if there are any pending transfers, incoming or outgoing, stay on this