-
Notifications
You must be signed in to change notification settings - Fork 1
Description
The REST API for Activity Feeds V3 returns collections for activities when collection refs are present in the activity:
{
"activities": [
{
"id": "...",
"text": "...",
"collections": { ... }
}
]
}
The autogenerated API layer already maps the collections field correctly:
// packages/stream_feeds/lib/src/generated/api/model/activity_response.g.dart
ActivityResponse _$ActivityResponseFromJson(Map<String, dynamic> json) =>
ActivityResponse(
collections: (json['collections'] as Map<String, dynamic>).map(
(k, e) => MapEntry(
k, EnrichedCollectionResponse.fromJson(e as Map<String, dynamic>)),
),
...
)
However, in the SDK the ActivityData model defined in packages/stream_feeds/lib/src/models/activity_data.dart does not include a property for collections, the data is also not propagated when mapping ActivityResponse to ActivityData, as shown below:
extension ActivityResponseMapper on ActivityResponse {
/// Converts this API activity response to a domain [ActivityData] instance.
///
/// This is a simplified implementation that works with the current project state.
/// Some fields are simplified or use placeholders until all dependencies are implemented.
ActivityData toModel() {
return ActivityData(
attachments: attachments,
bookmarkCount: bookmarkCount,
commentCount: commentCount,
comments: [...comments.map((c) => c.toModel())],
createdAt: createdAt,
currentFeed: currentFeed?.toModel(),
deletedAt: deletedAt,
editedAt: editedAt,
expiresAt: expiresAt,
feeds: feeds,
filterTags: filterTags,
id: id,
interestTags: interestTags,
isWatched: isWatched,
latestReactions: [...latestReactions.map((r) => r.toModel())],
location: location?.let(
(it) => LocationCoordinate(
latitude: it.lat,
longitude: it.lng,
),
),
mentionedUsers: [...mentionedUsers.map((u) => u.toModel())],
moderation: moderation?.toModel(),
notificationContext: notificationContext,
ownBookmarks: [...ownBookmarks.map((b) => b.toModel())],
ownReactions: [...ownReactions.map((r) => r.toModel())],
parent: parent?.toModel(),
poll: poll?.toModel(),
popularity: popularity,
hidden: hidden,
preview: preview,
reactionCount: reactionCount,
reactionGroups: {
for (final entry in reactionGroups.entries)
entry.key: entry.value.toModel(),
},
score: score,
searchData: searchData,
shareCount: shareCount,
text: text,
type: type,
updatedAt: updatedAt,
user: user.toModel(),
visibility: visibility.toModel(),
visibilityTag: visibilityTag,
custom: custom,
);
}
}
As a result, collection data is not accessible in Flutter clients even though it is returned by the API.
The documentation suggests collections are returned: https://getstream.io/activity-feeds/docs/flutter/collections/
Please consider adding a collections field to ActivityData and mapping it from ActivityResponse so this data can be accessed in the Flutter SDK.
Thank you!