Skip to content

Conversation

gpunto
Copy link
Contributor

@gpunto gpunto commented Sep 12, 2025

Goal

I was reviewing the events we handled and noticed some were missing, so the goal of this PR is to address those gaps.

Implementation

Most of the code is just adding some new handling code in XyzHandlers and delegate to the appropriate XyzStateUpdates:

  • Activity: Added handling for ActivityReactionAddedEvent, ActivityReactionDeletedEvent, ActivityUpdatedEvent, BookmarkAddedEvent, and BookmarkDeletedEvent
  • ActivityReactionList: Added handling for ActivityReactionAddedEvent
  • BookmarkList: Added handling for BookmarkDeletedEvent
  • CommentList: Added handling for CommentDeletedEvent
  • Feed: Added handling for ActivityRemovedFromFeedEvent
  • FeedList: Added handling for FeedDeletedEvent
  • FollowList: Added handling for FollowDeletedEvent
  • MemberList: Added handling for FeedMemberAddedEvent and improved filtering by fid
  • PollVoteList: Added handling for PollVoteCastedFeedEvent

Additionally, I took the opportunity to:

  • Unify reaction add/remove logic to ensure consistency
  • Update FeedsReactionData id to include comment id and type
  • Refactor some test code

Testing

The new code is covered by tests.

Testing this manually is not trivial in most cases. What I did was the following (taking BookmarkList as an example):

  • Add some code in FeedViewModel to query a BookmarkList, observe and log the results (list.state.bookmarks)
  • Launch the app and add/remove bookmarks that would match the query
  • Verify that the flow emitted the updated data

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 September 12, 2025 14:08
Copy link
Contributor

github-actions bot commented Sep 12, 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.

Copy link

@Copilot 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 adds missing event handling for various states to ensure comprehensive real-time updates across the Stream Feeds Android client. The implementation focuses on handling deletion events and some addition events that were previously not addressed.

Key changes include:

  • Addition of event handlers for deletion and update events across multiple state managers (Activity, Feed, Bookmark, Comment, Follow, and Member lists)
  • Unification of reaction add/remove logic through common utility functions
  • Update to FeedsReactionData ID generation to include comment ID and type for better uniqueness

Reviewed Changes

Copilot reviewed 39 out of 39 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ActivityEventHandler.kt Added handling for activity reaction, bookmark, and update events with proper feed/activity matching
FeedEventHandler.kt Added support for ActivityRemovedFromFeedEvent
Various list event handlers Added deletion event handling for bookmarks, comments, feeds, follows, and members
State implementations Added removal methods and updated existing logic to support new event types
FeedsReactionData.kt Updated ID generation to include commentId and type for better uniqueness
Reaction logic files Refactored to use unified reaction add/remove utility functions
Test files Added comprehensive test coverage for new event handling functionality
Comments suppressed due to low confidence (1)

stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/utils/List.kt:162

  • Removed documentation parameter @param T but the function still uses generic type T. The parameter documentation should be retained to explain the generic type parameter.
 * @param T The type of elements in the list.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

github-actions bot commented Sep 12, 2025

SDK Size Comparison 📏

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

@gpunto gpunto changed the title Handle missing events for various states Handle missing events for various state objects Sep 12, 2025
@gpunto gpunto added the pr:new-feature New feature label Sep 12, 2025
@@ -309,35 +304,18 @@ internal fun ActivityData.addReaction(
internal fun ActivityData.removeReaction(
reaction: FeedsReactionData,
currentUserId: String,
): ActivityData {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as for addReaction

Comment on lines -42 to +43
get() = "${activityId}${user.id}"
get() = "${activityId}${commentId}${user.id}${type}"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can have multiple reactions per activity & comment.

import io.getstream.feeds.android.client.api.model.isEmpty
import io.getstream.feeds.android.client.internal.utils.upsert

internal inline fun <T> addReaction(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The code in here and removeReaction comes from the corresponding extensions of ThreadedCommentData, adapted to be generic.

// It might be a nested reply, search and remove recursively
current.map { comment -> removeCommentFromReplies(comment, commentId) }
}
current.treeRemoveFirst(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replacing in favor of a generic function, like for CommentListStateImpl.

@gpunto gpunto requested a review from VelikovPetar September 12, 2025 14:36
@gpunto gpunto marked this pull request as ready for review September 12, 2025 14:36
@gpunto gpunto force-pushed the handle-missing-events branch from 4c0d8b6 to fc65bb7 Compare September 16, 2025 09:46
@gpunto gpunto force-pushed the handle-missing-events branch from fc65bb7 to bd30ecf Compare September 17, 2025 08:25
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.

2 participants