on master help sign in
Pull failure handling out of hook

and into the one view that uses it. Feels more intuitive/clear.

commit1ff1d11bcba7ae64a92b5e3bcf908ceee028199e authorFang <git@fang.io> dateThu 11 Jul 2019, 20:58 (7 years ago) parentd8ec87c
2 files changed+8−7
src/lib/useMailer.js+2−6 src/views/Invite/InviteEmail.js+6−1
src/lib/useMailer.js+2−6
@@ -43,14 +43,10 @@ export default function useMailer(emails) {
4343 const _sendMail = useCallback(async (email, ticket, rawTx) => {
4444 if (STUB_MAILER) {
4545 console.log(`${email} - ${ticket}`);
46− return;
46+ return true;
4747 }
4848
49− const mailSuccess = await sendMail(email, ticket, rawTx);
50−
51− if (!mailSuccess) {
52− throw new Error(`Internal mailing error when mailing ${email}`);
53− }
49+ return await sendMail(email, ticket, rawTx);
5450 }, []);
5551
5652 return { ...hasReceivedCache, sendMail: _sendMail };
src/views/Invite/InviteEmail.js+6−1
@@ -318,7 +318,12 @@ export default function InviteEmail() {
318318 }
319319
320320 try {
321− await sendMail(invite.email, invite.ticket, invite.rawTx);
321+ const success = await sendMail(
322+ invite.email,
323+ invite.ticket,
324+ invite.rawTx
325+ );
326+ if (!success) throw new Error('Failed to send mail');
322327 } catch (error) {
323328 console.error(error);
324329 errorCount++;