Compute isRead and isSeen flags based on notification status#186
Compute isRead and isSeen flags based on notification status#186
isRead and isSeen flags based on notification status#186Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
b7dfcbb to
fcec447
Compare
|
WalkthroughThe changes extend Changes
Sequence Diagram(s)sequenceDiagram
participant Network as Network Response
participant Ops as AggregatedActivityOperations
participant Model as AggregatedActivityData
participant State as FeedStateImpl
participant UI as UI Layer
Network->>Ops: Response with isRead,<br/>isSeen, isWatched
Ops->>Model: Map fields to<br/>AggregatedActivityData
Model->>State: toModel() returns<br/>populated model
State->>State: onNotificationFeedUpdated()<br/>with notificationStatus
State->>State: updateReadSeenStatus()<br/>derives read/seen<br/>from timestamps & ids
State->>Model: Update isRead/isSeen<br/>in aggregatedActivities
State->>UI: Emit updated<br/>aggregatedActivities
UI->>UI: Render using<br/>AggregatedActivityData.isRead
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~35 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.kt (1)
368-375:⚠️ Potential issue | 🟠 MajorCompute read/seen after merging incoming groups.
Line 372 updates the current aggregated groups, but Line 373 can immediately replace those groups with the incoming
aggregatedActivitiespayload and add new groups that never pass throughupdateReadSeenStatus. This can leave updated/new notification groups with stale ornullisRead/isSeendespite a non-nullnotificationStatus.🐛 Proposed fix
override fun onNotificationFeedUpdated( aggregatedActivities: List<AggregatedActivityData>, notificationStatus: NotificationStatusResponse?, ) { - notificationStatus?.let(::updateReadSeenStatus) updateAggregatedActivities(aggregatedActivities, prependNew = true) + notificationStatus?.let(::updateReadSeenStatus) _notificationStatus.update { notificationStatus } }The existing
FeedStateImplTestexpectation around incomingupdated/newgroups should also be adjusted to expect computed flags whennotificationStatusis present.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.kt` around lines 368 - 375, onNotificationFeedUpdated currently calls updateReadSeenStatus before updateAggregatedActivities which means newly merged or incoming groups never get their isRead/isSeen flags computed; swap the operations so you first call updateAggregatedActivities(aggregatedActivities, prependNew = true), then, if notificationStatus != null, call updateReadSeenStatus(notificationStatus) to compute flags on the merged groups, and finally update _notificationStatus via _notificationStatus.update { notificationStatus }; also update the FeedStateImplTest expectations to assert computed read/seen flags for updated/new groups when notificationStatus is present.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In
`@stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.kt`:
- Around line 368-375: onNotificationFeedUpdated currently calls
updateReadSeenStatus before updateAggregatedActivities which means newly merged
or incoming groups never get their isRead/isSeen flags computed; swap the
operations so you first call updateAggregatedActivities(aggregatedActivities,
prependNew = true), then, if notificationStatus != null, call
updateReadSeenStatus(notificationStatus) to compute flags on the merged groups,
and finally update _notificationStatus via _notificationStatus.update {
notificationStatus }; also update the FeedStateImplTest expectations to assert
computed read/seen flags for updated/new groups when notificationStatus is
present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 70700193-0528-492f-aeca-bac2a4eed037
📒 Files selected for processing (8)
stream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/api/model/AggregatedActivityData.ktstream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/model/AggregatedActivityOperations.ktstream-feeds-android-client/src/main/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImpl.ktstream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/FeedStateImplTest.ktstream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/state/event/handler/FeedEventHandlerTest.ktstream-feeds-android-client/src/test/kotlin/io/getstream/feeds/android/client/internal/test/TestData.ktstream-feeds-android-sample/src/main/java/io/getstream/feeds/android/sample/notification/NotificationsScreen.ktstream-feeds-android-sample/src/main/java/io/getstream/feeds/android/sample/notification/NotificationsViewModel.kt


Goal
We need to compute the two flags similarly to how the backend does it, i.e.:
Docs here.
Implementation
Testing
Checklist
Summary by CodeRabbit
New Features
Bug Fixes
Tests