Cancellation guard on contact info pane

This commit is contained in:
Jack Kingsman
2026-02-27 15:05:22 -08:00
parent 2e8a4fde0a
commit c40603a36f

View File

@@ -50,15 +50,25 @@ export function ContactInfoPane({
return;
}
let cancelled = false;
setLoading(true);
api
.getContactDetail(contactKey)
.then(setDetail)
.catch((err) => {
console.error('Failed to fetch contact detail:', err);
toast.error('Failed to load contact info');
.then((data) => {
if (!cancelled) setDetail(data);
})
.finally(() => setLoading(false));
.catch((err) => {
if (!cancelled) {
console.error('Failed to fetch contact detail:', err);
toast.error('Failed to load contact info');
}
})
.finally(() => {
if (!cancelled) setLoading(false);
});
return () => {
cancelled = true;
};
}, [contactKey]);
// Use live contact data where available, fall back to detail snapshot