@@ -75,7 +75,7 @@ export default function InviteCohort() {
75 const { contracts }: any = useNetwork();
75 const { contracts }: any = useNetwork();
76 const { syncControlledPoints }: any = usePointCache();
76 const { syncControlledPoints }: any = usePointCache();
78− const point = Just(pointCursor)
78+ const point = pointCursor.getOrElse(null);
79 const _contracts = need.contracts(contracts);
79 const _contracts = need.contracts(contracts);
81 const [numInvites, setNumInvites] = useState(
81 const [numInvites, setNumInvites] = useState(
@@ -83,13 +83,25 @@ export default function InviteCohort() {
84 const [showInviteForm, setShowInviteForm] = useState(false);
84 const [showInviteForm, setShowInviteForm] = useState(false);
85 const [loading, setLoading] = useState(false);
85 const [loading, setLoading] = useState(false);
86− const [error, setError] = useState('');
87 const [downloadingCsv, setDownloadingCsv] = useState(false);
86 const [downloadingCsv, setDownloadingCsv] = useState(false);
87+ const [error, setError] = useState('');
88 const [l1Invite, setL1Invite] = useState<L1Invite | null>(null);
88 const [l1Invite, setL1Invite] = useState<L1Invite | null>(null);
89 const [page, setPage] = useState(0);
89 const [page, setPage] = useState(0);
91 const { construct, unconstruct, completed, bind } = useIssueChild();
91 const { construct, unconstruct, completed, bind } = useIssueChild();
93+ const onClickShowInvite = useCallback(
94+ (planet: number) => {
96+ // Put this in a timeout to let the UI update
97+ setTimeout(async () => {
98+ await showInvite(planet);
102+ [setLoading, showInvite]
93 useEffect(() => {
105 useEffect(() => {
94 if (invitePoints.length > 0) {
106 if (invitePoints.length > 0) {
95 getInvites(currentL2);
107 getInvites(currentL2);
@@ -101,7 +113,7 @@ export default function InviteCohort() {
101 const _authToken = authToken.getOrElse(null);
113 const _authToken = authToken.getOrElse(null);
103 const setUpInvite = async () => {
115 const setUpInvite = async () => {
104− setLoading(true);
116+ setDownloadingCsv(true);
105 const possiblePoints = await azimuth.azimuth.getUnspawnedChildren(
117 const possiblePoints = await azimuth.azimuth.getUnspawnedChildren(
106 _contracts,
118 _contracts,
@@ -132,7 +144,7 @@ export default function InviteCohort() {
132 setError('No available planets');
144 setError('No available planets');
135− setLoading(false);
147+ setDownloadingCsv(false);
138 if (!currentL2 && _contracts && point && _authToken && showInviteForm) {
150 if (!currentL2 && _contracts && point && _authToken && showInviteForm) {
@@ -154,7 +166,12 @@ export default function InviteCohort() {
154 useEffect(() => {
166 useEffect(() => {
155 const storedInvites = getStoredInvites(ls);
167 const storedInvites = getStoredInvites(ls);
157− if (!completed || !l1Invite || storedInvites[l1Invite.planet]) {
173+ storedInvites[l1Invite.planet]
@@ -164,7 +181,7 @@ export default function InviteCohort() {
164 setL1Invite(null);
181 setL1Invite(null);
165 unconstruct();
182 unconstruct();
167− }, [completed]); // eslint-disable-line react-hooks/exhaustive-deps
184+ }, [completed, currentL2]); // eslint-disable-line react-hooks/exhaustive-deps
169 const invitesToDisplay = invites.slice(
186 const invitesToDisplay = invites.slice(
170 page * INVITES_PER_PAGE,
187 page * INVITES_PER_PAGE,
@@ -198,7 +215,7 @@ export default function InviteCohort() {
199 const downloadCsv = useCallback(() => {
216 const downloadCsv = useCallback(() => {
200 const generateAndDownload = async () => {
217 const generateAndDownload = async () => {
201− setDownloadingCsv(true);
218+ setLoading(true);
202 const invites = await getInvites(currentL2, true);
219 const invites = await getInvites(currentL2, true);
203 if (invites) {
220 if (invites) {
204 const csv = invites.reduce(
221 const csv = invites.reduce(
@@ -218,14 +235,14 @@ export default function InviteCohort() {
219 setError('There was an error creating the CSV');
236 setError('There was an error creating the CSV');
221− setDownloadingCsv(false);
238+ setLoading(false);
222 setInviteGeneratingNum(0);
239 setInviteGeneratingNum(0);
224 generateAndDownload();
241 generateAndDownload();
226 getInvites,
243 getInvites,
227 setError,
244 setError,
228− setDownloadingCsv,
245+ setLoading,
229 setInviteGeneratingNum,
246 setInviteGeneratingNum,
230 currentL2,
247 currentL2,
@@ -261,7 +278,7 @@ export default function InviteCohort() {
263 className="secondary"
280 className="secondary"
264− onClick={() => showInvite(invite.planet)}>
281+ onClick={() => onClickShowInvite(invite.planet)}>
265 Show Invite
282 Show Invite
266 </Button2>
283 </Button2>
@@ -437,7 +454,10 @@ export default function InviteCohort() {
438 </Button>
455 </Button>
440− <LoadingOverlay loading={downloadingCsv} text={downloadingCsvText} />
458+ loading={downloadingCsv || loading}
459+ text={downloadingCsv ? downloadingCsvText : undefined}