Skip to content

Conversation

@gpunto
Copy link
Contributor

@gpunto gpunto commented Nov 14, 2025

Goal

Concludes AND-893

The feature is described here, but the summary is that usually feed apps don't automatically add new activities in a live fashion. It usually happens only when the current user posts a new activity, so this is going to be our default behavior. However, we are also adding a way to customize it, should the integrators choose to do so.

Implementation

  • Add onNewActivity property in FeedQuery
  • Update Feed event handler & state to honor the action returned by onNewActivity

Testing

In the sample, you can try adding an activity from the current user and from another user (in a different device) and verify that only in the first case is the activity added to the (top of the) feed.

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@gpunto gpunto requested a review from Copilot November 14, 2025 11:13
@gpunto gpunto added the pr:new-feature New feature label Nov 14, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 14, 2025

SDK Size Comparison 📏

SDK Before After Difference Status
stream-feeds-android-client 2.36 MB 2.36 MB 0.00 MB 🟢

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a customizable callback mechanism to control how new activities from WebSocket events are added to feeds. By default, only activities created by the current user that match the feed's activity filter are automatically inserted at the start of the feed, while all other activities are ignored. This behavior can be customized via the onNewActivity callback parameter in FeedQuery.

  • Added InsertionAction enum to specify whether and where to insert new activities
  • Introduced onNewActivity callback in FeedQuery with a sensible default implementation
  • Updated event handling pipeline to use the callback and honor insertion actions

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
InsertionAction.kt Defines the enum for specifying insertion behavior (AddToStart, AddToEnd, Ignore)
FeedQuery.kt Adds the onNewActivity callback parameter with default implementation
OnNewActivityDefault.kt Implements the default behavior: add to start only for current user's activities that match the filter
FeedEventHandler.kt Invokes the onNewActivity callback and passes the result to state updates
FeedStateImpl.kt Handles all three insertion actions when adding new activities
List.kt Extends upsert function to support prepending elements
TestData.kt Makes user parameter customizable in test data factory
OnNewActivityDefaultTest.kt Tests the default callback implementation with various scenarios
FeedEventHandlerTest.kt Updates tests to verify insertion action handling
FeedStateImplTest.kt Tests all three insertion actions (Ignore, AddToStart, AddToEnd)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Base automatically changed from and-904/update-fid-based-filtering to develop November 25, 2025 09:07
@gpunto gpunto force-pushed the and-893/change-activity-added-handling branch from 24733d6 to aa1e618 Compare November 25, 2025 09:12
@gpunto gpunto marked this pull request as ready for review November 25, 2025 09:20
@gpunto gpunto marked this pull request as draft November 27, 2025 10:07
@sonarqubecloud
Copy link

@gpunto gpunto marked this pull request as ready for review November 27, 2025 11:05
* limitations under the License.
*/

package io.getstream.feeds.android.client.api.state
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not particularly convinced about using this package. Suggestions are welcome

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The InsertionAction is kinda related to state updates, so I think it is fine 🤷‍♂️ Another option would be maybe to introduce a feed package and place it there -> but that would mean that we should re-organise the whole package structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but that would mean that we should re-organise the whole package structure.

😨

The InsertionAction is kinda related to state updates, so I think it is fine

Then let's keep it as it is. I often find it difficult to organize packages, especially when there's just 1 file that seems to not fit well anywhere. 😓

@gpunto gpunto merged commit b216adc into develop Nov 27, 2025
7 checks passed
@gpunto gpunto deleted the and-893/change-activity-added-handling branch November 27, 2025 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:new-feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants