Skip to content

Commit d08e4e9

Browse files
authored
fix(llc): Improve on local FeedsReactionData id (#52)
1 parent 6926cb7 commit d08e4e9

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/stream_feeds/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## unreleased
22
- Update follower and following counts on the feed state when receiving follow websocket events.
3+
- Fix FeedsReactionData id for updating reactions in the feed state.
34

45
## 0.3.1
56
- Update API client with renaming `addReaction` to `addActivityReaction` and `deleteReaction` to `deleteActivityReaction`.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class FeedsReactionData with _$FeedsReactionData {
1414
/// Creates a new [FeedsReactionData] instance.
1515
const FeedsReactionData({
1616
required this.activityId,
17+
this.commentId,
1718
required this.createdAt,
1819
required this.type,
1920
required this.updatedAt,
@@ -25,6 +26,8 @@ class FeedsReactionData with _$FeedsReactionData {
2526
@override
2627
final String activityId;
2728

29+
final String? commentId;
30+
2831
/// The date and time when the reaction was created.
2932
@override
3033
final DateTime createdAt;
@@ -46,7 +49,8 @@ class FeedsReactionData with _$FeedsReactionData {
4649
final Map<String, Object?>? custom;
4750

4851
/// Unique identifier for the reaction, generated from the activity ID and user ID.
49-
String get id => '$activityId${user.id}';
52+
String get id =>
53+
'${user.id}-$type${commentId == null ? '' : '-$commentId'}-$activityId';
5054
}
5155

5256
/// Extension function to convert a [FeedsReactionResponse] to a [FeedsReactionData] model.
@@ -55,6 +59,7 @@ extension FeedsReactionResponseMapper on FeedsReactionResponse {
5559
FeedsReactionData toModel() {
5660
return FeedsReactionData(
5761
activityId: activityId,
62+
commentId: commentId,
5863
createdAt: createdAt,
5964
type: type,
6065
updatedAt: updatedAt,

0 commit comments

Comments
 (0)