on master help sign in
Disallow sending when email service hasn't responded
cf8ece3Fang
src/views/Invite/InviteEmail.js+16−9
@@ -189,24 +189,30 @@ export default function InviteEmail() {
189 }
189 }
190
190
191 //TODO want to do this on-input, but that gets weird. see #188
191 //TODO want to do this on-input, but that gets weird. see #188
192− let errorCount = 0;
192+ let knowAll = true;
193+ let alreadyReceived = [];
193 await Promise.all(
194 await Promise.all(
194 inputs.map(async input => {
195 inputs.map(async input => {
195 const email = input.data;
196 const email = input.data;
196 const hasReceived = getHasReceived(email).matchWith({
197 const hasReceived = getHasReceived(email).matchWith({
197− Nothing: () => false, // loading
198+ Nothing: () => 'unknown', // loading
198 Just: p => p.value,
199 Just: p => p.value,
199 });
200 });
200− if (hasReceived) {
201+ if (hasReceived === 'unknown') {
201− errorCount++;
202+ knowAll = false;
202− addError({
203+ } else if (hasReceived) {
203− [input.name]: `${email} has already received an invite.`,
204+ alreadyReceived.push(email);
204− });
205 }
205 }
206 })
206 })
207 );
207 );
208− if (errorCount > 0) {
208+ if (!knowAll) {
209+ throw new Error('No word yet from email service...');
210+ }
211+ if (alreadyReceived.length > 0) {
209− throw new Error(`Some of these already have a point!`);
212+ throw new Error(
213+ 'The following recipients already own a point: ' +
214+ alreadyReceived.join(', ')
215+ );
210 }
216 }
211
217
212 const nonce = await _web3.eth.getTransactionCount(_wallet.address);
218 const nonce = await _web3.eth.getTransactionCount(_wallet.address);
@@ -231,6 +237,7 @@ export default function InviteEmail() {
231
237
232 clearInvites();
238 clearInvites();
233 // NB(shrugs) - must be processed in serial because main thread, etc
239 // NB(shrugs) - must be processed in serial because main thread, etc
240+ let errorCount = 0;
234 for (let i = 0; i < inputs.length; i++) {
241 for (let i = 0; i < inputs.length; i++) {
235 const input = inputs[i];
242 const input = inputs[i];
236 try {
243 try {