-
Notifications
You must be signed in to change notification settings - Fork 26
Refactor procedures list handling and improve error/retry states with new components #1664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Bundestag List screen by extracting data fetching and rendering logic into custom hooks and creating dedicated error/retry state components to improve maintainability and user experience.
Key Changes:
- Extracted data fetching logic into
useProceduresListhook with enhanced retry mechanism - Moved list item rendering logic into
useProceduresListItemRendererhook - Added dedicated
ErrorStateandRetryStatecomponents for better error handling
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/screens/Bundestag/List/index.tsx |
Simplified main component by removing inline logic and using new hooks and components |
src/screens/Bundestag/List/hooks/useProceduresListItemRenderer.tsx |
New hook that extracts list item rendering logic with proper memoization |
src/screens/Bundestag/List/hooks/useProceduresList.ts |
New hook that manages data fetching, retry logic, and segmented data processing |
src/screens/Bundestag/List/Components/RetryState.tsx |
New component for displaying retry state with loading indicator and remaining attempts |
src/screens/Bundestag/List/Components/ErrorState.tsx |
New component for displaying error state with retry button |
f79d3f3 to
8a6b1a3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
8a6b1a3 to
0f2be22
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
| const isNotLoading = !loading; | ||
| const hasErrorOrNoData = !!error || !data; | ||
| const isRetryActive = isRetryScheduled || retryAttempt > 0; | ||
| const hasRemainingAttempts = retryAttempt < MAX_RETRY_ATTEMPTS; | ||
| const isRetrying = | ||
| isNotLoading && hasErrorOrNoData && isRetryActive && hasRemainingAttempts; |
Copilot
AI
Sep 27, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These intermediate boolean variables add unnecessary complexity. Consider simplifying the retry state logic by directly computing isRetrying or consolidating related conditions.
| const isNotLoading = !loading; | |
| const hasErrorOrNoData = !!error || !data; | |
| const isRetryActive = isRetryScheduled || retryAttempt > 0; | |
| const hasRemainingAttempts = retryAttempt < MAX_RETRY_ATTEMPTS; | |
| const isRetrying = | |
| isNotLoading && hasErrorOrNoData && isRetryActive && hasRemainingAttempts; | |
| const isRetrying = | |
| !loading && | |
| (!!error || !data) && | |
| (isRetryScheduled || retryAttempt > 0) && | |
| retryAttempt < MAX_RETRY_ATTEMPTS; |
This pull request refactors the Bundestag List screen by modularizing its logic and improving error and retry handling. The main changes include extracting data fetching and item rendering logic into custom hooks, introducing dedicated components for error and retry states, and simplifying the main list component for better readability and maintainability.
Refactoring and Modularization:
useProceduresList, which manages loading, error, retry attempts, and data segmentation for the list.useProceduresListItemRendererfor cleaner separation of concerns and easier testing.Error and Retry Handling Improvements:
ErrorStateandRetryStateto provide clearer user feedback and actions during connection errors and automatic retry attempts. [1] [2]Codebase Simplification:
Listcomponent, delegating all data and UI state management to the new hooks and components. [1] [2] [3]