Skip to content

Conversation

@ManAnRuck
Copy link
Member

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:

  • Extracted data fetching logic into a new custom hook useProceduresList, which manages loading, error, retry attempts, and data segmentation for the list.
  • Moved list item rendering logic into a separate hook useProceduresListItemRenderer for cleaner separation of concerns and easier testing.

Error and Retry Handling Improvements:

  • Added new components ErrorState and RetryState to provide clearer user feedback and actions during connection errors and automatic retry attempts. [1] [2]
  • Updated the main list component to use the new error and retry state components, and to trigger manual and automatic retries using the new hooks.

Codebase Simplification:

  • Removed redundant state and logic from the main List component, delegating all data and UI state management to the new hooks and components. [1] [2] [3]

@ManAnRuck ManAnRuck self-assigned this Sep 27, 2025
Copilot AI review requested due to automatic review settings September 27, 2025 13:46
@ManAnRuck ManAnRuck moved this to ⚙️ In Progress in Democracy Sep 27, 2025
Copy link
Contributor

Copilot AI left a 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 useProceduresList hook with enhanced retry mechanism
  • Moved list item rendering logic into useProceduresListItemRenderer hook
  • Added dedicated ErrorState and RetryState components 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

@ManAnRuck ManAnRuck force-pushed the feature/list-reloading branch from f79d3f3 to 8a6b1a3 Compare September 27, 2025 14:14
@ManAnRuck ManAnRuck requested a review from Copilot September 27, 2025 14:15
Copy link
Contributor

Copilot AI left a 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.

@ManAnRuck ManAnRuck force-pushed the feature/list-reloading branch from 8a6b1a3 to 0f2be22 Compare September 27, 2025 14:34
@ManAnRuck ManAnRuck requested a review from Copilot September 27, 2025 14:35
Copy link
Contributor

Copilot AI left a 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.

Comment on lines +199 to +204
const isNotLoading = !loading;
const hasErrorOrNoData = !!error || !data;
const isRetryActive = isRetryScheduled || retryAttempt > 0;
const hasRemainingAttempts = retryAttempt < MAX_RETRY_ATTEMPTS;
const isRetrying =
isNotLoading && hasErrorOrNoData && isRetryActive && hasRemainingAttempts;
Copy link

Copilot AI Sep 27, 2025

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.

Suggested change
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;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ⚙️ In Progress

Development

Successfully merging this pull request may close these issues.

2 participants