Skip to content

Commit 165db41

Browse files
committed
fix(archived headlines ): undo UI refresh
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.
1 parent a8d2b3a commit 165db41

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

lib/content_management/bloc/archived_headlines/archived_headlines_bloc.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ class ArchivedHeadlinesBloc
3232
_onDeletionServiceStatusChanged,
3333
); // Handle deletion service events
3434

35-
// Listen to deletion events from the PendingDeletionsService
36-
_deletionEventSubscription = _pendingDeletionsService.deletionEvents
37-
.where(
38-
(event) => event.id.startsWith('headline_'),
39-
) // Filter for headline deletions
40-
.listen((event) => add(_DeletionServiceStatusChanged(event)));
35+
// Listen to deletion events from the PendingDeletionsService.
36+
// The filter now correctly checks the type of the item in the event.
37+
_deletionEventSubscription = _pendingDeletionsService.deletionEvents.listen(
38+
(event) {
39+
if (event.item is Headline) {
40+
add(_DeletionServiceStatusChanged(event));
41+
}
42+
},
43+
);
4144

4245
on<DeleteHeadlineForeverRequested>(_onDeleteHeadlineForeverRequested);
4346
on<UndoDeleteHeadlineRequested>(_onUndoDeleteHeadlineRequested);

0 commit comments

Comments
 (0)