Skip to content

feat(llc): update isRead/isSeen flags on mark events - #112

Open
renefloor wants to merge 3 commits into
mainfrom
renefloor/flu-418-update-flutter-sdk-for-new-readseen-and-own-fields-behavior
Open

feat(llc): update isRead/isSeen flags on mark events#112
renefloor wants to merge 3 commits into
mainfrom
renefloor/flu-418-update-flutter-sdk-for-new-readseen-and-own-fields-behavior

Conversation

@renefloor

@renefloor renefloor commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • markRead, markSeen, markAllRead, and markAllSeen in FeedState now update per-activity ActivityData.isRead/isSeen and per-group AggregatedActivityData.isRead/isSeen flags in addition to the aggregate notificationStatus counts. These flags now stay in sync when the activity.marked WebSocket event fires.
  • Updated docs/code_snippets/05_06_notification_feeds.dart with functions showing per-activity/per-group isRead/isSeen access and mark-specific-groups-as-read pattern.
  • Created docs/code_snippets/08_01_events.dart showing how to observe feed state changes via feed.stream.

Closes FLU-418

Test plan

  • melos run analyze — no issues
  • melos run format — no changes
  • flutter test in packages/stream_feeds — 392 tests pass
  • dart analyze docs/ — snippets compile

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Notification read/seen status now stays consistent across feeds, grouped notifications, and individual activities, even after updates from another device or session.
    • Added examples showing how to inspect feed events and mark only selected notification groups as read.
  • Bug Fixes

    • Preserves existing notification and feed details when updates arrive without complete data.
    • Group-level and item-level read/seen states now refresh correctly after mark-read, mark-seen, and feed update actions.

markRead, markSeen, markAllRead, and markAllSeen now update the
per-activity and per-group isRead/isSeen flags on the feed state
when the activity.marked WebSocket event fires, in addition to the
existing aggregate notification-status counts.

Closes FLU-418

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@renefloor
renefloor requested a review from a team as a code owner June 17, 2026 12:58
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: eef17734-596b-43f7-b7a0-c7c11b6b0bed

📥 Commits

Reviewing files that changed from the base of the PR and between a1590dd and 7a21a42.

📒 Files selected for processing (10)
  • docs/code_snippets/05_06_notification_feeds.dart
  • docs/code_snippets/08_01_events.dart
  • packages/stream_feeds/CHANGELOG.md
  • packages/stream_feeds/lib/src/models/activity_data.dart
  • packages/stream_feeds/lib/src/models/feed_data.dart
  • packages/stream_feeds/lib/src/state/event/handler/feed_event_handler.dart
  • packages/stream_feeds/lib/src/state/event/state_update_event.dart
  • packages/stream_feeds/lib/src/state/feed.dart
  • packages/stream_feeds/lib/src/state/feed_state.dart
  • packages/stream_feeds/test/state/feed_test.dart

📝 Walkthrough

Walkthrough

Adds a hasOwnFields flag threaded through ActivityUpdated/FeedUpdated events and model merge methods (ActivityData.updateWith, FeedDataMutations.updateWith) to gate whether server-provided own_* fields overwrite local state. Reworks FeedState/FeedStateNotifier to reconcile per-activity/per-group isRead/isSeen flags on activity queries, updates, and mark operations. Updates changelog, tests, and documentation snippets accordingly.

Changes

hasOwnFields gating and notification read/seen reconciliation

Layer / File(s) Summary
Model and event contracts for hasOwnFields
packages/stream_feeds/lib/src/state/event/state_update_event.dart, packages/stream_feeds/lib/src/models/activity_data.dart, packages/stream_feeds/lib/src/models/feed_data.dart
ActivityUpdated/FeedUpdated gain a hasOwnFields field; ActivityData.updateWith and FeedDataMutations.updateWith are rewritten to preserve own_* fields by default and take them from updated only when hasOwnFields is true.
Event emission wiring
packages/stream_feeds/lib/src/state/feed.dart, packages/stream_feeds/lib/src/state/event/handler/feed_event_handler.dart
Feed.updateFeed/updateActivity/updateActivityPartial emit hasOwnFields from request.enrichOwnFields, and FeedEventHandler forwards it into state.onActivityUpdated/onFeedUpdated.
Feed state read/seen reconciliation
packages/stream_feeds/lib/src/state/feed_state.dart
onActivityUpdated/onFeedUpdated accept hasOwnFields; onQueryMoreActivities and onNotificationFeedUpdated call reconcileReadSeen(); markAllRead/markAllSeen/markRead/markSeen and reconcileReadSeen() recompute isRead/isSeen from lastReadAt/lastSeenAt and readActivities/seenActivities.
Feed state test coverage
packages/stream_feeds/test/state/feed_test.dart
Adds tests for enrichOwnFields effects on ownFollowings, ownReactions, ownBookmarks, and currentFeed.ownFollowings, and rewrites mark/notification tests to validate group-level and nested-activity isRead/isSeen including a status-only update test.
Changelog and documentation snippets
packages/stream_feeds/CHANGELOG.md, docs/code_snippets/05_06_notification_feeds.dart, docs/code_snippets/08_01_events.dart
Documents the new read/seen sync behavior and adds example functions for reading per-activity/group state, marking a specific group as read, and listening to client/feed events with unread/unseen counts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Feed
  participant FeedEventHandler
  participant FeedState

  Feed->>FeedEventHandler: emit ActivityUpdated(activity, hasOwnFields)
  Feed->>FeedEventHandler: emit FeedUpdated(feed, hasOwnFields)
  FeedEventHandler->>FeedState: onActivityUpdated(activity, hasOwnFields)
  FeedState->>FeedState: ActivityData.updateWith(hasOwnFields)
  FeedEventHandler->>FeedState: onFeedUpdated(feed, hasOwnFields)
  FeedState->>FeedState: FeedData.updateWith(hasOwnFields)
Loading
sequenceDiagram
  participant Client
  participant FeedState
  participant NotificationStatus

  Client->>FeedState: markRead(['group1'])
  FeedState->>NotificationStatus: update readActivities, lastReadAt
  FeedState->>FeedState: reconcileReadSeen()
  FeedState->>FeedState: recompute group and nested activity isRead/isSeen
  FeedState-->>Client: updated aggregatedActivities
Loading

Possibly related PRs

  • GetStream/stream-feeds-flutter#64: Prior refactor of ActivityData.updateWith preserving ownBookmarks/ownReactions is directly extended here with hasOwnFields gating.
  • GetStream/stream-feeds-flutter#69: Prior changes to FeedDataMutations.updateWith in feed_data.dart are directly rewritten in this PR to add hasOwnFields gating.
  • GetStream/stream-feeds-flutter#79: Prior StateUpdateEvent-based state management refactor is extended here by adding hasOwnFields to ActivityUpdated/FeedUpdated and forwarding it in feed_event_handler.dart.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: syncing read/seen flags for mark events.
Description check ✅ Passed The description includes a clear summary, linked issue, and test plan, and is mostly complete despite missing CLA and screenshots sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch renefloor/flu-418-update-flutter-sdk-for-new-readseen-and-own-fields-behavior

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.50746% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.82%. Comparing base (a1590dd) to head (7a21a42).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/stream_feeds/lib/src/state/feed_state.dart 97.91% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #112      +/-   ##
==========================================
+ Coverage   85.53%   85.82%   +0.28%     
==========================================
  Files         124      124              
  Lines        4342     4381      +39     
==========================================
+ Hits         3714     3760      +46     
+ Misses        628      621       -7     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor
renefloor marked this pull request as draft June 18, 2026 13:45
@renefloor
renefloor marked this pull request as ready for review July 9, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant