Skip to content

Conversation

gpunto
Copy link
Contributor

@gpunto gpunto commented Oct 3, 2025

Goal

Exact same story as #91, but for Feed. This concludes the migration from WSEvent to StateUpdateEvent, so now every "controller" object (Activity, ActivityList, etc) should be updating automatically even if we are not receiving socket events.

Implementation

  • Change handler from WSEvent to StateUpdateEvent
  • Fire events from FeedImpl instead of updating the state directly
Before Now
_state.onFeedUpdated(feed) subscriptionManager.onEvent(FeedUpdated(feed))
  • I also realized that for some operations that should result in a state update, FeedImpl was not updating the state (e.g. updateBookmark), so updated those also to fire events

Testing

Similar instructions as #91, but this time even the feed should be updating. E.g. disable listening to the socket, test doing operations in the sample like adding a comment, voting on a poll, etc, and everything should be updating accordingly.

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 3, 2025 08:17
Copy link
Contributor

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

Migrates the Feed component from consuming WebSocket events to consuming and firing state update events. This continues the architectural change started in #91, bringing Feed in line with other controller objects like Activity and ActivityList for consistent state management.

  • Updated Feed event handling to use StateUpdateEvent instead of WSEvent
  • Changed FeedImpl to fire events through subscription manager instead of updating state directly
  • Added feed parameter to comment events and updated existing activity deletion events for consistency

Reviewed Changes

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

Show a summary per file
File Description
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/event/handler/FeedEventHandler.kt Updated to handle StateUpdateEvent instead of WSEvent with simplified feed matching logic
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedImpl.kt Changed to fire StateUpdateEvent through subscription manager instead of direct state updates
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/event/StateUpdateEvent.kt Added new event types and feed parameters to existing comment/activity events
stream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/event/handler/FeedEventHandlerTest.kt Comprehensive rewrite to test StateUpdateEvent handling with feed matching logic
Multiple test files Updated test calls to match new event signatures with feed parameters
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/repository/FeedsRepositoryImpl.kt Updated unfollow to return FollowData instead of Unit for proper event firing

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 3, 2025
Copy link
Contributor

github-actions bot commented Oct 3, 2025

SDK Size Comparison 📏

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

@gpunto gpunto requested a review from Copilot October 3, 2025 08:27
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 22 out of 22 changed files in this pull request and generated no new comments.


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

@gpunto gpunto requested a review from Copilot October 3, 2025 09:30
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 23 out of 23 changed files in this pull request and generated 2 comments.


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

val result = feed.updateFeedMembers(request)

assertEquals(memberUpdates, result.getOrNull())
assertEquals(memberUpdates.updated, feed.state.members.value)
Copy link
Preview

Copilot AI Oct 3, 2025

Choose a reason for hiding this comment

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

The test expects memberUpdates.updated but the mock setup has added = listOf(feedMemberData("user1")) and updated = emptyList(). This assertion should use memberUpdates.added to match the mock data.

Suggested change
assertEquals(memberUpdates.updated, feed.state.members.value)
assertEquals(memberUpdates.added, feed.state.members.value)

Copilot uses AI. Check for mistakes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks to this comment I realized there's an actual bug in the logic, i.e. we're never taking care of updates.added. Will fix that in a separate PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing in #93

import org.junit.runners.Parameterized

@RunWith(Parameterized::class)
internal class StateUpdateEventToModelTest(
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 bowed to SonarCloud's request because .toModel() wasn't covered at all, but I'm not 100% convinced this test is super useful.

@gpunto gpunto marked this pull request as ready for review October 3, 2025 10:44
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 23 out of 23 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/event/StateUpdateEvent.kt:1

  • [nitpick] The import statements are not in alphabetical order. Consider sorting them alphabetically for better maintainability.
/*

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

override suspend fun rejectFeedMember(): Result<FeedMemberData> {
return feedsRepository.rejectFeedMember(feedGroupId = group, feedId = id)
return feedsRepository.rejectFeedMember(feedGroupId = group, feedId = id).onSuccess {
subscriptionManager.onEvent(StateUpdateEvent.FeedMemberRemoved(fid.rawValue, it.id))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quick question: Can we treat rejectFeedMember as a StateUpdateEvent.FeedMemberRemoved? Is the member in this case already a part of the feed members?

Copy link
Contributor Author

@gpunto gpunto Oct 3, 2025

Choose a reason for hiding this comment

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

Good catch, we actually can't. It seems that in the backend this results in an update, not a removal. I'll change it accordingly.

cc @laevandus I think you have the same issue on iOS

Copy link
Contributor Author

@gpunto gpunto Oct 3, 2025

Choose a reason for hiding this comment

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

Copy link

sonarqubecloud bot commented Oct 3, 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.

2 participants