on master help sign in
Disallow sending when email service hasn't responded
commitcf8ece34b9a5cc3f2acbff74ac3c83ce36640254 authorFang <git@fang.io> dateFri 26 Jul 2019, 21:51 (7 years ago) parenta017d40
1 file changed+16−9
src/views/Invite/InviteEmail.js+16−9
src/views/Invite/InviteEmail.js+16−9
@@ -189,24 +189,30 @@ export default function InviteEmail() {
189189 }
190190
191191 //TODO want to do this on-input, but that gets weird. see #188
192− let errorCount = 0;
192+ let knowAll = true;
193+ let alreadyReceived = [];
193194 await Promise.all(
194195 inputs.map(async input => {
195196 const email = input.data;
196197 const hasReceived = getHasReceived(email).matchWith({
197− Nothing: () => false, // loading
198+ Nothing: () => 'unknown', // loading
198199 Just: p => p.value,
199200 });
200− if (hasReceived) {
201− errorCount++;
202− addError({
203− [input.name]: `${email} has already received an invite.`,
204− });
201+ if (hasReceived === 'unknown') {
202+ knowAll = false;
203+ } else if (hasReceived) {
204+ alreadyReceived.push(email);
205205 }
206206 })
207207 );
208− if (errorCount > 0) {
209− throw new Error(`Some of these already have a point!`);
208+ if (!knowAll) {
209+ throw new Error('No word yet from email service...');
210+ }
211+ if (alreadyReceived.length > 0) {
212+ throw new Error(
213+ 'The following recipients already own a point: ' +
214+ alreadyReceived.join(', ')
215+ );
210216 }
211217
212218 const nonce = await _web3.eth.getTransactionCount(_wallet.address);
@@ -231,6 +237,7 @@ export default function InviteEmail() {
231237
232238 clearInvites();
233239 // NB(shrugs) - must be processed in serial because main thread, etc
240+ let errorCount = 0;
234241 for (let i = 0; i < inputs.length; i++) {
235242 const input = inputs[i];
236243 try {