Skip to content

Commit 371dcac

Browse files
committed
fix(community_management): implement workaround for Engagement comment nulling bug
- Replace Engagement.copyWith with manual instantiation to set comment to null - Add TODO comment for potential future fix in the core model - Update updatedAt timestamp for the engagement
1 parent 952bc6e commit 371dcac

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/community_management/bloc/community_management_bloc.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,21 @@ class CommunityManagementBloc
334334
(e) => e.id == event.engagementId,
335335
);
336336

337-
final updatedEngagement = originalEngagement.copyWith(
338-
comment: null,
337+
// TODO(fulleni) Fic the following BUG:
338+
// The original Engagement.copyWith method has a bug where
339+
// `comment: comment ?? this.comment` prevents setting the comment to null.
340+
// To work around this without modifying the core model, we must create a
341+
// new instance of Engagement manually, copying all properties and
342+
// explicitly setting the comment to null.
343+
final updatedEngagement = Engagement(
344+
id: originalEngagement.id,
345+
userId: originalEngagement.userId,
346+
entityId: originalEngagement.entityId,
347+
entityType: originalEngagement.entityType,
348+
reaction: originalEngagement.reaction,
349+
createdAt: originalEngagement.createdAt,
350+
updatedAt: DateTime.now(),
351+
comment: null, // Explicitly set to null to reject/delete the comment.
339352
);
340353

341354
final updatedEngagements = List<Engagement>.from(state.engagements)

0 commit comments

Comments
 (0)