Skip to content

Conversation

gpunto
Copy link
Contributor

@gpunto gpunto commented Oct 7, 2025

Goal

Part of AND-796

I'm adding missing handling for some events. This PR does that for BookmarkUpdated. I also took the chance to simplify the logic to update bookmarks on events.

Implementation

  • Add handling of BookmarkUpdated where needed
  • Merge handling of addition & updates, treating them as upsertions
  • Simplify logic to update bookmarks on events, i.e. now we take whatever came from backend as source of truth except ownBookmarks, so we only compute those

Testing

For testing that adding/deleting bookmarks still works, it's just a matter of launching the sample and testing it manually. For updates it's not easy, as we don't have anything in the sample that would trigger it. It would require adding code that changes an existing bookmark, e.g. changing its folder.

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 7, 2025 07:59
Copy link
Contributor

github-actions bot commented Oct 7, 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 handling for the BookmarkUpdated event and simplifies bookmark change logic by treating both additions and updates as upsert operations.

  • Add handling for BookmarkUpdated events across all relevant event handlers
  • Unify bookmark addition and update logic into a single onBookmarkUpserted method
  • Simplify bookmark state updates by using backend data as source of truth, only computing ownBookmarks separately

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TestData.kt Add createdAt parameter to test bookmark factory method
FeedEventHandlerTest.kt Add test for BookmarkUpdated event handling
BookmarkListEventHandlerTest.kt Refactor tests to use parameterized approach and update bookmark handlers
ActivityListEventHandlerTest.kt Add test for BookmarkUpdated event and update existing handlers
ActivityEventHandlerTest.kt Add test for BookmarkUpdated event handling
FeedStateImplTest.kt Update tests to use onBookmarkUpserted method
FeedImplTest.kt Simplify bookmark addition test logic
BookmarkListStateImplTest.kt Replace onBookmarkUpdated with onBookmarkUpserted and improve test structure
ActivityStateImplTest.kt Update tests to use onBookmarkUpserted method
ActivityListStateImplTest.kt Update tests to use onBookmarkUpserted method
FeedEventHandler.kt Add handling for BookmarkUpdated events
BookmarkListEventHandler.kt Add BookmarkAdded and BookmarkUpdated handling with upsert logic
ActivityListEventHandler.kt Add BookmarkUpdated handling and update existing handlers
ActivityEventHandler.kt Add handling for BookmarkUpdated events
FeedStateImpl.kt Replace separate add/update methods with unified onBookmarkUpserted
BookmarkListStateImpl.kt Replace onBookmarkUpdated with onBookmarkUpserted using sorted upsert
ActivityStateImpl.kt Replace separate add/update methods with unified onBookmarkUpserted
ActivityListStateImpl.kt Replace separate add/update methods with unified onBookmarkUpserted
ActivityData.kt Simplify bookmark change logic with unified changeBookmarks helper

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

@gpunto gpunto added the pr:new-feature New feature label Oct 7, 2025
@gpunto gpunto changed the title Simplify bookmark change logic & handle bookmark updated event Handle bookmark updated event Oct 7, 2025
@gpunto gpunto changed the title Handle bookmark updated event Add handling for bookmark updated event Oct 7, 2025
@gpunto gpunto requested a review from Copilot October 7, 2025 08:00
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

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


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 Oct 7, 2025

SDK Size Comparison 📏

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

@gpunto gpunto marked this pull request as ready for review October 7, 2025 09:12
Comment on lines +245 to +259
internal fun List<ActivityData>.deleteBookmark(
bookmark: BookmarkData,
currentUserId: String,
): List<ActivityData> =
updateIf({ it.id == bookmark.activity.id }) { activity ->
activity.deleteBookmark(bookmark, currentUserId)
}

internal fun List<ActivityData>.upsertBookmark(
bookmark: BookmarkData,
currentUserId: String,
): List<ActivityData> =
updateIf({ it.id == bookmark.activity.id }) { activity ->
activity.upsertBookmark(bookmark, currentUserId)
}
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 introduced these two on List to address the duplication found by Sonar and be able to merge. However, the duplication was scheduled to disappear because of some changes in a future PR, so I'll remove them at that point.

Copy link

sonarqubecloud bot commented Oct 7, 2025

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.

1 participant