-
Notifications
You must be signed in to change notification settings - Fork 0
Migrate Feed
to consuming and firing state update events
#92
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
base: develop
Are you sure you want to change the base?
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
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
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.
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Outdated
Show resolved
Hide resolved
...in/kotlin/io/getstream/feeds/android/client/internal/state/event/handler/FeedEventHandler.kt
Show resolved
Hide resolved
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
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.
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
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.
...t/src/main/kotlin/io/getstream/feeds/android/client/internal/state/event/StateUpdateEvent.kt
Show resolved
Hide resolved
val result = feed.updateFeedMembers(request) | ||
|
||
assertEquals(memberUpdates, result.getOrNull()) | ||
assertEquals(memberUpdates.updated, feed.state.members.value) |
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 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.
assertEquals(memberUpdates.updated, feed.state.members.value) | |
assertEquals(memberUpdates.added, feed.state.members.value) |
Copilot uses AI. Check for mistakes.
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.
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
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.
Fixing in #93
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
internal class StateUpdateEventToModelTest( |
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 bowed to SonarCloud's request because .toModel()
wasn't covered at all, but I'm not 100% convinced this test is super useful.
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
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.
...s-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.kt
Show resolved
Hide resolved
...in/kotlin/io/getstream/feeds/android/client/internal/state/event/handler/FeedEventHandler.kt
Show resolved
Hide resolved
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)) |
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.
Quick question: Can we treat rejectFeedMember
as a StateUpdateEvent.FeedMemberRemoved
? Is the member in this case already a part of the feed members?
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.
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
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.
Btw, the same seems to apply to acceptFeedMember
|
Goal
Exact same story as #91, but for
Feed
. This concludes the migration fromWSEvent
toStateUpdateEvent
, so now every "controller" object (Activity
,ActivityList
, etc) should be updating automatically even if we are not receiving socket events.Implementation
WSEvent
toStateUpdateEvent
FeedImpl
instead of updating the state directly_state.onFeedUpdated(feed)
subscriptionManager.onEvent(FeedUpdated(feed))
FeedImpl
was not updating the state (e.g.updateBookmark
), so updated those also to fire eventsTesting
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