Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

fix(web): prevent stale responses from overwriting results (#682)

Bharadwajjjjj20067d358d8e
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
index 75d611c57..6f582b740 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/page.tsx
@@ -169,7 +169,7 @@ export default function ContentPage() {
const pager = usePagination(total, `${statusFilter}|${impactFilter}|${typeFilter}`);
const loadData = useCallback(
- async (silent = false) => {
+ async (silent = false, isCancelled?: () => boolean) => {
if (!activeBrandId) {
setOpportunities([]);
setTotal(0);
@@ -191,6 +191,7 @@ export default function ContentPage() {
offset: pager.start,
sort: 'score',
});
+ if (isCancelled?.()) return;
setOpportunities(data.opportunities);
setTotal(data.total);
return data.total;
@@ -199,14 +200,22 @@ export default function ContentPage() {
toast.error('Failed to load content opportunities');
return 0;
} finally {
- setLoading(false);
+ if (!isCancelled?.()) {
+ setLoading(false);
+ }
}
},
[activeBrandId, statusFilter, impactFilter, typeFilter, pager.start],
);
useEffect(() => {
- loadData();
+ let cancelled = false;
+
+ loadData(false, () => cancelled);
+
+ return () => {
+ cancelled = true;
+ };
}, [loadData]);
const pollJob = useCallback(