Skip to content

Standardize client data fetching with a shared, cancelable useApiResource hook - #1148

Open
mrmoney10010-design wants to merge 3 commits into
rinafcode:mainfrom
mrmoney10010-design:refactor-api-resource
Open

Standardize client data fetching with a shared, cancelable useApiResource hook#1148
mrmoney10010-design wants to merge 3 commits into
rinafcode:mainfrom
mrmoney10010-design:refactor-api-resource

Conversation

@mrmoney10010-design

Copy link
Copy Markdown

The panel components all fetch through apiClient but each unwraps the response differently and handles the lifecycle inconsistently. src/components/ai/SmartNotifications.tsx reads res.data, src/components/ai/PersonalizedRecommendations.tsx reads r.items, src/components/ai/NaturalLanguageQuery.tsx reads r.results, and src/components/ai/LearningAssistant.tsx reads r.reply, while src/components/ai/IntelligentProgress.tsx and src/components/social/FollowingSystem.tsx read the payload directly. Only SmartNotifications guards against setState-after-unmount; the others can update unmounted components, and none pass an AbortSignal even though src/lib/api.ts (RequestConfig extends RequestInit) and src/hooks/useAbortController.ts already support cancellation. src/types/api.ts defines ApiResponse but it is applied inconsistently, so each panel reinvents its own loading/error state.

closes #1137

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Well done on the job done so far1
Kindly resolve conflict and make workflow pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize client data fetching with a shared, cancelable useApiResource hook

2 participants