Skip to content

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Sep 21, 2025

Status

READY

Description

This pull request significantly improves the 'undo delete' feature for archived headlines by introducing a dedicated PendingDeletionsService. This new service centralizes the logic for managing timed deletions and their potential reversal, enhancing the robustness and maintainability of the feature. The ArchivedHeadlinesBloc and its associated UI are updated to integrate with this service, ensuring a consistent and reliable user experience for managing deleted headlines. Additionally, the BlocObserver logging has been enhanced for better debugging, and several minor code cleanups have been performed across various UI components.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

…ding deletions

- Add pendingDeletions map to track optimistic deletions
- Implement lastPendingDeletionId to manage undo operations
- Expand ArchivedHeadlinesStatus with initial, loading, success, and failure states
- Update copyWith method to support new properties
- Add extensive documentation for class and properties
…nt with id

- Add 'id' parameter to UndoDeleteHeadlineRequested event
- Implement props getter for UndoDeleteHeadlineRequested event
…headlines

- Implement individual subscriptions for each pending deletion to allow independent undo operations.
- Add optimistic UI updates for delete and restore actions.
- Enhance error handling and state management for failed operations.
- Introduce detailed documentation for bloc methods and functionality.
- Refactor timer-based deletion to a stream-based approach for better control and testability.
- Replace lastDeletedHeadline check with pendingDeletions length comparison
- Add support for undoing multiple deletions
- Update SnackBar action to use the correct headline ID for undo operation
…ions

- Implement PendingDeletionsService abstract class and its implementation
- Add DeletionStatus enum and DeletionEvent class
- Service allows requesting deletions with an undo period
- Emits events when deletions are confirmed or undone
- Handles multiple pending deletions and ensures proper cleanup
- Simplify and update comments for pendingDeletions and lastPendingDeletionId
- Explicitly allow null for lastPendingDeletionId in copyWith method
- Rename and update existing events in archived headlines BLoC
- Add new events for clearing restored headlines and handling deletion service updates
- Improve documentation and code structure for better readability and maintainability
…for improved undo functionality

- Replace individual deletion subscriptions with a single service for better memory management
- Optimize state updates for deletion, undo, and restore operations
- Externalize deletion logic to enhance testability and separation of concerns
- Add support for clearing restored headlines from state
…unctionality

- Add PendingDeletionsService to manage undo operations
- Implement headline restoration and main list refresh
- Enhance undo functionality with snackbar notification
- Optimize state management and event handling
- Implement PendingDeletionsService for managing undoable deletions
- Add service to App widget and bootstrap process
- Provide the service through RepositoryProvider for dependency injection
- Replace print statements with dart:developer/log for better logging practices
- Implement selective logging of state 'status' property when available
- Add error handling and logging for accessing status property
- Truncate long state string representations to 250 characters
- Suppress dynamic calls lint for the file
…e undo functionality

- Add generic type T to DeletionEvent to allow associating the item with the event
- Implement undoDeletion with the ability to return the original item
- Refactor PendingDeletionsServiceImpl to use a private _PendingDeletion class
- Update deletionEvents stream to use dynamic type for better flexibility
…barHeadlineTitle

- Remove pendingDeletions map from ArchivedHeadlinesState
- Add snackbarHeadlineTitle to store the title of the headline for which the snackbar should be displayed
- Update copyWith method to reflect changes
- Update props list in ArchivedHeadlinesState to include new field
…eadlines

- Specify generic type for DeletionEvent in _DeletionServiceStatusChanged event
…ement

- Remove pendingDeletions map from ArchivedHeadlinesState
- Simplify deletion undo logic by checking item type
- Add snackbarHeadlineTitle to state for managing snackbar content
- Update related emissions in bloc to reflect changes
…tions handling

- Move snackbar logic out of the state and into the view
- Replace direct BLoC access with PendingDeletionsService for undo action
- Optimize state comparison for snackbar triggers
- Simplify headline deletion snackbar display
Corrected the stream subscription in ArchivedHeadlinesBloc to properly filter
and process DeletionEvent for Headline items. This ensures that when a user
undoes a deletion from the snackbar within the archived headlines page, the
UI immediately reflects the restored item.
@gemini-code-assist
Copy link

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the 'undo delete' feature for archived headlines by introducing a dedicated PendingDeletionsService. This new service centralizes the logic for managing timed deletions and their potential reversal, enhancing the robustness and maintainability of the feature. The ArchivedHeadlinesBloc and its associated UI are updated to integrate with this service, ensuring a consistent and reliable user experience for managing deleted headlines. Additionally, the BlocObserver logging has been enhanced for better debugging, and several minor code cleanups have been performed across various UI components.

Highlights

  • New Pending Deletions Service: Introduced a new PendingDeletionsService to centralize and manage timed deletions with undo functionality across the application. This service handles the lifecycle of deletion timers and emits events for confirmed or undone deletions.
  • Refactored Headline Deletion Logic: The ArchivedHeadlinesBloc has been refactored to utilize the new PendingDeletionsService for handling headline deletions and undo operations. This removes the previous internal Timer logic, making the deletion process more robust and consistent.
  • Enhanced Bloc Logging: The BlocObserver has been updated to provide more concise and informative logging for state changes. It now prioritizes displaying a status property if available in the BLoC state, otherwise truncates the full state string to prevent excessively long logs.
  • Application-wide Service Integration: The App widget and bootstrap function have been updated to instantiate and provide the PendingDeletionsService to the widget tree, ensuring it's available for dependency injection where needed.
  • UI Updates for Undo Feature: The ArchivedHeadlinesPage UI now correctly interacts with the PendingDeletionsService for triggering undo actions via the snackbar, improving the user experience for recovering deleted headlines.
  • Code Cleanup and Readability: Numerous minor code cleanups were performed across various files, including the removal of redundant comments, simplification of where clauses, and removal of explicit textAlign and crossAxisAlignment comments, enhancing overall code readability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively refactors the undo-delete functionality into a new, reusable PendingDeletionsService, which is a significant improvement for maintainability. The introduction of a more detailed AppBlocObserver will also be very helpful for debugging. The rest of the changes consist of minor but welcome code cleanup. I've identified a critical runtime bug related to the initialization of the new service that must be addressed, along with a few medium-severity suggestions to enhance type safety and code readability.

- Remove unnecessary initialization of PendingDeletionsServiceImpl
- This change simplifies the bootstrap process and reduces unnecessary code
- Simplify index calculation for restored headlines
- Enhance readability and performance of insertion logic
@fulleni fulleni merged commit 065b4e5 into main Sep 21, 2025
1 check failed
@fulleni fulleni deleted the fix-headlines-undo-delete-feature branch September 21, 2025 16:44
@fulleni fulleni added this to the Foundation Edition milestone Nov 1, 2025
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.

2 participants