Skip to content

Commit fd49c67

Browse files
committed
fix updates on unmodifiable list
1 parent cba38f2 commit fd49c67

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

packages/stream_feeds/lib/src/models.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export 'models/feeds_reaction_data.dart';
77
export 'models/identifiable.dart';
88
export 'models/reaction_group_data.dart';
99
export 'models/user_data.dart';
10-
export 'models/get_or_create_feed_data.dart';
10+
export 'models/get_or_create_feed_data.dart';

packages/stream_feeds/lib/src/models/activity_data.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ class ActivityData implements Identifiable {
4545
final newLatestReactions = [...latestReactions];
4646
final newReactionGroups =
4747
Map<String, ReactionGroupData>.from(reactionGroups);
48-
var newOwnReactions = ownReactions;
48+
var newOwnReactions = [...ownReactions];
4949

5050
reaction.updateByAdding(
51-
to: [...latestReactions],
51+
to: newLatestReactions,
5252
reactionGroups: newReactionGroups,
5353
);
5454
if (reaction.user.id == currentUserId) {
55-
newOwnReactions = ownReactions.insertById(reaction);
55+
newOwnReactions = newOwnReactions.insertById(reaction);
5656
}
5757

5858
return copyWith(
59-
reactionCount: reactionCount + 1,
59+
reactionCount: newLatestReactions.length,
6060
latestReactions: List.unmodifiable(newLatestReactions),
61-
ownReactions: newOwnReactions,
61+
ownReactions: List.unmodifiable(newOwnReactions),
6262
reactionGroups: Map.unmodifiable(newReactionGroups),
6363
);
6464
}
@@ -68,20 +68,20 @@ class ActivityData implements Identifiable {
6868
final newLatestReactions = [...latestReactions];
6969
final newReactionGroups =
7070
Map<String, ReactionGroupData>.from(reactionGroups);
71-
var newOwnReactions = ownReactions;
71+
var newOwnReactions = [...ownReactions];
7272

7373
reaction.updateByRemoving(
74-
to: [...latestReactions],
74+
to: newLatestReactions,
7575
reactionGroups: newReactionGroups,
7676
);
7777
if (reaction.user.id == currentUserId) {
78-
newOwnReactions = ownReactions.removeById(reaction);
78+
newOwnReactions = newOwnReactions.removeById(reaction);
7979
}
8080

8181
return copyWith(
82-
reactionCount: reactionCount - 1,
82+
reactionCount: newLatestReactions.length,
8383
latestReactions: List.unmodifiable(newLatestReactions),
84-
ownReactions: newOwnReactions,
84+
ownReactions: List.unmodifiable(newOwnReactions),
8585
reactionGroups: Map.unmodifiable(newReactionGroups),
8686
);
8787
}

packages/stream_feeds/lib/src/models/get_or_create_feed_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class GetOrCreateFeedData {
77
});
88

99
final PaginationResult<ActivityData> activities;
10-
}
10+
}

0 commit comments

Comments
 (0)