Skip to content

Commit 413c903

Browse files
committed
fix(feed_decorator): update logic for marking decorators as completed
- Modify the logic for updating UserFeedDecoratorStatus - Ensure once a decorator is marked as completed, it stays completed - Always update the `lastShownAt` timestamp - Introduce conditional update for `isCompleted` flag
1 parent 3578ef0 commit 413c903

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/app/bloc/app_bloc.dart

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,22 @@ class AppBloc extends Bloc<AppEvent, AppState> {
510510
// Get the current status for the decorator, or create a default if not present.
511511
final currentStatus =
512512
state.user!.feedDecoratorStatus[event.feedDecoratorType] ??
513-
const UserFeedDecoratorStatus(isCompleted: false);
514-
515-
// Create an updated status, preserving the `isCompleted` flag and only
516-
// updating the `lastShownAt` timestamp.
517-
final updatedDecoratorStatus = currentStatus.copyWith(lastShownAt: now);
513+
const UserFeedDecoratorStatus(isCompleted: false);
514+
515+
// Create an updated status.
516+
// It always updates the `lastShownAt` timestamp.
517+
// It updates `isCompleted` to true if the event marks it as completed.
518+
// Once completed, it should stay completed.
519+
final updatedDecoratorStatus = currentStatus.copyWith(
520+
lastShownAt: now,
521+
isCompleted: event.isCompleted || currentStatus.isCompleted,
522+
);
518523

519524
// Create a new map with the updated status for the specific decorator type.
520525
final newFeedDecoratorStatus =
521526
Map<FeedDecoratorType, UserFeedDecoratorStatus>.from(
522-
state.user!.feedDecoratorStatus,
523-
)..update(
527+
state.user!.feedDecoratorStatus,
528+
)..update(
524529
event.feedDecoratorType,
525530
(_) => updatedDecoratorStatus,
526531
ifAbsent: () => updatedDecoratorStatus,

0 commit comments

Comments
 (0)