Resolve linting errors

This commit is contained in:
Dries Augustyns
2026-05-01 19:55:58 +02:00
parent bb72911fa2
commit 532293e52a
+9 -15
View File
@@ -50,8 +50,6 @@ export function ContactPicker({
// Paste mode // Paste mode
const [pasteText, setPasteText] = useState(''); 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 [subscribeNew, setSubscribeNew] = useState(true);
const [debouncedPaste, setDebouncedPaste] = useState(''); const [debouncedPaste, setDebouncedPaste] = useState('');
const pasteDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null); const pasteDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);
@@ -72,17 +70,14 @@ export function ContactPicker({
}; };
}, [pasteText]); }, [pasteText]);
useEffect(() => { const debouncedEmails = parseEmails(debouncedPaste).filter(e => !existing.includes(e));
const emails = parseEmails(debouncedPaste).filter(e => !existing.includes(e)); const {data: preview, isLoading: isLooking} = useSWR(
if (emails.length === 0) { debouncedEmails.length > 0 ? ['/contacts/lookup', ...debouncedEmails] : null,
setPreview(null); () => network.fetch<{found: string[]; notFound: string[]}, typeof ContactSchemas.lookup>(
return; 'POST', '/contacts/lookup', {emails: debouncedEmails},
} ),
setIsLooking(true); {revalidateOnFocus: false},
network.fetch<{found: string[]; notFound: string[]}, typeof ContactSchemas.lookup>( );
'POST', '/contacts/lookup', {emails},
).then(setPreview).finally(() => setIsLooking(false));
}, [debouncedPaste]);
const {data, isLoading} = useSWR<CursorPaginatedResponse<Contact>>( const {data, isLoading} = useSWR<CursorPaginatedResponse<Contact>>(
open && debouncedSearch.length > 0 ? `/contacts?limit=20&search=${encodeURIComponent(debouncedSearch)}` : null, open && debouncedSearch.length > 0 ? `/contacts?limit=20&search=${encodeURIComponent(debouncedSearch)}` : null,
@@ -106,7 +101,6 @@ export function ContactPicker({
if (newPastedEmails.length === 0) return; if (newPastedEmails.length === 0) return;
await onAdd(newPastedEmails, subscribeNew); await onAdd(newPastedEmails, subscribeNew);
setPasteText(''); setPasteText('');
setPreview(null);
}; };
const visibleChips = selected.slice(0, CHIP_LIMIT); const visibleChips = selected.slice(0, CHIP_LIMIT);
@@ -254,7 +248,7 @@ export function ContactPicker({
<p className="text-xs text-neutral-400">Accepts newline, comma, or semicolon-separated addresses</p> <p className="text-xs text-neutral-400">Accepts newline, comma, or semicolon-separated addresses</p>
) : isLooking ? ( ) : isLooking ? (
<p className="flex items-center gap-1.5 text-xs text-neutral-400"><Loader2 className="h-3 w-3 animate-spin" /> Checking...</p> <p className="flex items-center gap-1.5 text-xs text-neutral-400"><Loader2 className="h-3 w-3 animate-spin" /> Checking...</p>
) : preview ? ( ) : newPastedEmails.length > 0 && preview ? (
<div className="rounded-md border border-neutral-200 divide-y divide-neutral-100 text-sm overflow-hidden"> <div className="rounded-md border border-neutral-200 divide-y divide-neutral-100 text-sm overflow-hidden">
{preview.found.length > 0 && ( {preview.found.length > 0 && (
<div className="flex items-center gap-2 px-3 py-2.5 text-neutral-700"> <div className="flex items-center gap-2 px-3 py-2.5 text-neutral-700">