@@ -18,6 +18,7 @@ import 'state/bookmark_list.dart';
1818import 'state/comment_list.dart' ;
1919import 'state/comment_reaction_list.dart' ;
2020import 'state/comment_reply_list.dart' ;
21+ import 'state/event/on_activity_added.dart' ;
2122import 'state/feed.dart' ;
2223import 'state/feed_list.dart' ;
2324import 'state/follow_list.dart' ;
@@ -223,6 +224,11 @@ abstract interface class StreamFeedsClient {
223224 /// Creates a [Feed] object using a [FeedQuery] that can include additional
224225 /// configuration such as activity filters, limits, and feed data for creation.
225226 ///
227+ /// When [onNewActivity] is provided, it customizes how new activities received
228+ /// via real-time events are inserted into the feed. When null, uses the default
229+ /// behavior which adds activities created by the current user to the start of
230+ /// the feed if they match the feed's filter.
231+ ///
226232 /// Example:
227233 /// ```dart
228234 /// final feed = client.feedFromQuery(FeedQuery(
@@ -236,7 +242,10 @@ abstract interface class StreamFeedsClient {
236242 /// ```
237243 ///
238244 /// Returns a [Feed] instance that can be used to interact with the specified feed.
239- Feed feedFromQuery (FeedQuery query);
245+ Feed feedFromQuery (
246+ FeedQuery query, {
247+ OnNewActivity onNewActivity,
248+ });
240249
241250 /// Creates a feed list instance based on the provided [query] .
242251 ///
@@ -764,6 +773,11 @@ extension StreamFeedsClientHelpers on StreamFeedsClient {
764773 /// Creates a [Feed] object that represents a specific feed.
765774 /// The feed can be used to fetch activities, manage follows, and receive real-time updates.
766775 ///
776+ /// When [onNewActivity] is provided, it customizes how new activities received
777+ /// via real-time events are inserted into the feed. Defaults to [defaultOnNewActivity] ,
778+ /// which adds activities created by the current user to the start of the feed
779+ /// if they match the feed's filter.
780+ ///
767781 /// Example:
768782 /// ```dart
769783 /// final userFeed = client.feed('user', 'john');
@@ -783,16 +797,25 @@ extension StreamFeedsClientHelpers on StreamFeedsClient {
783797 /// ```
784798 ///
785799 /// Returns a [Feed] instance that can be used to interact with the specified feed.
786- Feed feed ({required String group, required String id}) {
800+ Feed feed ({
801+ required String group,
802+ required String id,
803+ OnNewActivity onNewActivity = defaultOnNewActivity,
804+ }) {
787805 final fid = FeedId (group: group, id: id);
788- return feedFromId (fid);
806+ return feedFromId (fid, onNewActivity : onNewActivity );
789807 }
790808
791809 /// Creates a feed instance for the specified [fid] .
792810 ///
793811 /// Creates a [Feed] object that represents a specific feed.
794812 /// The feed can be used to fetch activities, manage follows, and receive real-time updates.
795813 ///
814+ /// When [onNewActivity] is provided, it customizes how new activities received
815+ /// via real-time events are inserted into the feed. Defaults to [defaultOnNewActivity] ,
816+ /// which adds activities created by the current user to the start of the feed
817+ /// if they match the feed's filter.
818+ ///
796819 /// Example:
797820 /// ```dart
798821 /// final feedId = FeedId(group: 'user', id: 'john');
@@ -802,8 +825,11 @@ extension StreamFeedsClientHelpers on StreamFeedsClient {
802825 /// ```
803826 ///
804827 /// Returns a [Feed] instance that can be used to interact with the specified feed.
805- Feed feedFromId (FeedId fid) {
828+ Feed feedFromId (
829+ FeedId fid, {
830+ OnNewActivity onNewActivity = defaultOnNewActivity,
831+ }) {
806832 final query = FeedQuery (fid: fid);
807- return feedFromQuery (query);
833+ return feedFromQuery (query, onNewActivity : onNewActivity );
808834 }
809835}
0 commit comments