From 532293e52a68fb60949da9fa7349ec4daebd105e Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Fri, 1 May 2026 19:55:58 +0200 Subject: [PATCH] Resolve linting errors --- apps/web/src/components/ContactPicker.tsx | 24 +++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/apps/web/src/components/ContactPicker.tsx b/apps/web/src/components/ContactPicker.tsx index bd30cf2..d3037bf 100644 --- a/apps/web/src/components/ContactPicker.tsx +++ b/apps/web/src/components/ContactPicker.tsx @@ -50,8 +50,6 @@ export function ContactPicker({ // Paste mode const [pasteText, setPasteText] = useState(''); - const [isLooking, setIsLooking] = useState(false); - const [preview, setPreview] = useState<{found: string[]; notFound: string[]} | null>(null); const [subscribeNew, setSubscribeNew] = useState(true); const [debouncedPaste, setDebouncedPaste] = useState(''); const pasteDebounceRef = useRef | null>(null); @@ -72,17 +70,14 @@ export function ContactPicker({ }; }, [pasteText]); - useEffect(() => { - const emails = parseEmails(debouncedPaste).filter(e => !existing.includes(e)); - if (emails.length === 0) { - setPreview(null); - return; - } - setIsLooking(true); - network.fetch<{found: string[]; notFound: string[]}, typeof ContactSchemas.lookup>( - 'POST', '/contacts/lookup', {emails}, - ).then(setPreview).finally(() => setIsLooking(false)); - }, [debouncedPaste]); + const debouncedEmails = parseEmails(debouncedPaste).filter(e => !existing.includes(e)); + const {data: preview, isLoading: isLooking} = useSWR( + debouncedEmails.length > 0 ? ['/contacts/lookup', ...debouncedEmails] : null, + () => network.fetch<{found: string[]; notFound: string[]}, typeof ContactSchemas.lookup>( + 'POST', '/contacts/lookup', {emails: debouncedEmails}, + ), + {revalidateOnFocus: false}, + ); const {data, isLoading} = useSWR>( open && debouncedSearch.length > 0 ? `/contacts?limit=20&search=${encodeURIComponent(debouncedSearch)}` : null, @@ -106,7 +101,6 @@ export function ContactPicker({ if (newPastedEmails.length === 0) return; await onAdd(newPastedEmails, subscribeNew); setPasteText(''); - setPreview(null); }; const visibleChips = selected.slice(0, CHIP_LIMIT); @@ -254,7 +248,7 @@ export function ContactPicker({

Accepts newline, comma, or semicolon-separated addresses

) : isLooking ? (

Checking...

- ) : preview ? ( + ) : newPastedEmails.length > 0 && preview ? (
{preview.found.length > 0 && (