1import { useCallback, useRef } from 'react';
3import { hasReceived, sendMail } from './inviteMail';
5const STUB_MAILER = process.env.REACT_APP_STUB_MAILER === 'true';
7export default function useMailer(emails) {
8 const cache = useRef({});
10 const getHasReceived = useCallback(
12 if (!cache.current[email]) {
14 cache.current[email] = false;
16 cache.current[email] = await hasReceived(email);
20 return cache.current[email];
25 // prefix to avoid clobbering sendMail import
26 // also throws if return value is false
27 const _sendMail = useCallback(async (email, ticket, sender, rawTx) => {
29 console.log(`${email} - ${ticket}`);
33 const success = await sendMail(email, ticket, sender, rawTx);
35 throw new Error('Failed to send mail');
39 return { getHasReceived, sendMail: _sendMail };
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list