-
Notifications
You must be signed in to change notification settings - Fork 1
Introduce callback to customize how new activities are handled in a feed #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
There was a problem hiding this 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
InsertionActionenum to specify whether and where to insert new activities - Introduced
onNewActivitycallback inFeedQuerywith 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.
...eeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/utils/List.kt
Outdated
Show resolved
Hide resolved
...ndroid-client/src/main/kotlin/io/getstream/feeds/android/client/api/state/query/FeedQuery.kt
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
24733d6 to
aa1e618
Compare
...oid-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.kt
Outdated
Show resolved
Hide resolved
...ndroid-client/src/main/kotlin/io/getstream/feeds/android/client/api/state/query/FeedQuery.kt
Outdated
Show resolved
Hide resolved
|
| * limitations under the License. | ||
| */ | ||
|
|
||
| package io.getstream.feeds.android.client.api.state |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😓



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
onNewActivityproperty inFeedQueryonNewActivityTesting
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