Skip to content

Conversation

@gpunto
Copy link
Contributor

@gpunto gpunto commented Oct 31, 2025

Goal

AND-800

When we upsert reactions in an ActivityReactionList, we should keep the sorting.

Implementation

  • Move to upsertSorted instead of upsert
  • Also took the chance to remove tree update functions to replace them with more specific ones, since they had only one usage and it doesn't make sense to maintain the complexity that came with the generic function

Testing

As similar cases, we don't show ActivityReactionList in the sample, so for testing one would need to create and observe a reaction list, and then add a reaction to the corresponding activity to see that it's inserted in order.

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 October 31, 2025 10:07
@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 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.

@gpunto gpunto added the pr:bug Bug fix label Oct 31, 2025
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 refactors comment and reaction list management by removing generic tree update utilities and replacing them with specialized, domain-specific functions. The changes improve code maintainability by making the codebase more focused on specific use cases rather than generic tree manipulation.

  • Removed generic tree update/remove functions (treeUpdateFirst, treeRemoveFirst) from List.kt
  • Introduced domain-specific removeComment functions in ThreadedCommentOperations.kt for handling comment removal in threaded structures
  • Updated ActivityReactionListStateImpl to use upsertSorted instead of upsert for maintaining sorted reaction lists
  • Added test coverage for sorted reaction insertion behavior

Reviewed Changes

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

Show a summary per file
File Description
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/utils/ListTreeUpdateTest.kt Removed entire test file for generic tree update functions that are no longer used
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/utils/List.kt Removed generic tree update/remove functions (treeUpdateFirst, treeRemoveFirst, internalTreeUpdate)
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/model/ThreadedCommentOperations.kt Added specialized removeComment and removeReply functions for threaded comment removal
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/CommentReplyListStateImpl.kt Refactored to use new removeComment function instead of manual filtering/recursion
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/ActivityCommentListStateImpl.kt Replaced treeRemoveFirst call with new removeComment function
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/ActivityReactionListStateImpl.kt Changed from upsert to upsertSorted to maintain sorted order when inserting reactions
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/ActivityReactionListStateImplTest.kt Updated test data calls to use named parameters and added new test for sorted insertion behavior

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

@github-actions
Copy link
Contributor

SDK Size Comparison 📏

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

@sonarqubecloud
Copy link

@gpunto gpunto marked this pull request as ready for review October 31, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants