@@ -1,4 +1,4 @@
1−import { useCallback, useEffect, useMemo, useState } from 'react';
1+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2import * as azimuth from 'azimuth-js';
2import * as azimuth from 'azimuth-js';
3import * as need from 'lib/need';
3import * as need from 'lib/need';
4import SecureLS from 'secure-ls';
4import SecureLS from 'secure-ls';
@@ -92,13 +92,12 @@ export default function useRoller() {
92 const { setNextRoll } = useTimerStore();
92 const { setNextRoll } = useTimerStore();
96 nextBatchTime,
95 nextBatchTime,
99 pointList,
98 pointList,
100 nextQuotaTime,
99 nextQuotaTime,
101− removeInvite,
100+ addInvite,
102 setNextBatchTime,
101 setNextBatchTime,
103 setNextQuotaTime,
102 setNextQuotaTime,
104 setPendingTransactions,
103 setPendingTransactions,
@@ -107,11 +106,11 @@ export default function useRoller() {
107 setInvitesLoading,
106 setInvitesLoading,
108 setModalText,
107 setModalText,
109 setPoints,
108 setPoints,
111 updatePoint,
109 updatePoint,
112 storePendingL1Txn,
110 storePendingL1Txn,
113 deletePendingL1Txn,
111 deletePendingL1Txn,
114 } = useRollerStore();
112 } = useRollerStore();
113+ const generatingInvites = useRef(false);
115 const [config, setConfig] = useState<Config | null>(null);
114 const [config, setConfig] = useState<Config | null>(null);
117 const options: Options = useMemo(() => {
116 const options: Options = useMemo(() => {
@@ -360,10 +359,11 @@ export default function useRoller() {
362 const getInvites = useCallback(async () => {
361 const getInvites = useCallback(async () => {
363− if (invitesLoading) {
362+ if (generatingInvites.current) {
366+ generatingInvites.current = true;
368 setInvitesLoading(true);
368 setInvitesLoading(true);
369 const curPoint: number = Number(need.point(pointCursor));
369 const curPoint: number = Number(need.point(pointCursor));
@@ -397,10 +397,7 @@ export default function useRoller() {
397 .filter((p: number) => !pendingSpawns.has(p))
397 .filter((p: number) => !pendingSpawns.has(p))
400− setInvites(
400+ setInvites(curPoint, []);
402− invitePlanets.map(p => inviteTemplate(p))
405 const newInvites: Invite[] = [];
402 const newInvites: Invite[] = [];
406 // Iterate over all of the stored invites, generating wallet info as necessary
403 // Iterate over all of the stored invites, generating wallet info as necessary
@@ -422,23 +419,23 @@ export default function useRoller() {
422 planetInfo.ownership?.owner?.address &&
419 planetInfo.ownership?.owner?.address &&
423 planetInfo.dominion === POINT_DOMINIONS.L2
420 planetInfo.dominion === POINT_DOMINIONS.L2
422+ addInvite(curPoint, invite);
425 newInvites.push(invite);
423 newInvites.push(invite);
426− updateInvite(curPoint, invite);
428− removeInvite(curPoint, invite.planet);
431 if (storedInvite) {
426 if (storedInvite) {
432 setStoredInvite(ls, invite);
427 setStoredInvite(ls, invite);
435− setInvites(curPoint, newInvites);
430+
436 setInvitesLoading(false);
431 setInvitesLoading(false);
437 return newInvites;
432 return newInvites;
439 } catch (error) {
434 } catch (error) {
440 console.warn('ERROR GETTING INVITES', error);
435 console.warn('ERROR GETTING INVITES', error);
438+ generatingInvites.current = false;
444 authToken,
441 authToken,
@@ -447,12 +444,11 @@ export default function useRoller() {
449 pointList,
446 pointList,
450− removeInvite,
447+ addInvite,
451 setInvites,
448 setInvites,
452 setInvitesLoading,
449 setInvitesLoading,
453 setInviteGeneratingNum,
450 setInviteGeneratingNum,
454 setPendingTransactions,
451 setPendingTransactions,
458 const generateInviteCodes = useCallback(
454 const generateInviteCodes = useCallback(
@@ -571,6 +567,7 @@ export default function useRoller() {
573 setStoredInvites(ls, invites);
569 setStoredInvites(ls, invites);
570+ console.log('getting invites from code generation');
574 getInvites();
571 getInvites();
575 showNotification(
572 showNotification(
576 `Your invite${invites.length > 1 ? 's have' : ' has'} been generated!`
573 `Your invite${invites.length > 1 ? 's have' : ' has'} been generated!`
@@ -1053,6 +1050,7 @@ export default function useRoller() {
1054 setTimeout(() => {
1051 setTimeout(() => {
1055 if (!point.isDefault) {
1052 if (!point.isDefault) {
1053+ console.log('getting invites from batch time');
1056 getInvites(); // This will also get pending txns
1054 getInvites(); // This will also get pending txns
1058 }, TEN_SECONDS); // Should this be more like a minute?
1056 }, TEN_SECONDS); // Should this be more like a minute?