Skip to content

Conversation

@xsahil03x
Copy link
Member

@xsahil03x xsahil03x commented Jan 9, 2026

Description of the pull request

Refactor the unread notification logic to account for the lastReadAt timestamp in addition to the readActivities list.

This ensures that notifications are correctly marked as read if their updatedAt timestamp is before the lastReadAt time. The _isNotificationRead and _hasUnreadNotifications methods have been updated to reflect this improved logic.

Summary by CodeRabbit

  • Bug Fixes
    • Improved unread notification detection by centralizing read/unread logic and using timestamp comparisons, yielding more accurate and consistent notification status in the feed.

✏️ Tip: You can customize this high-level summary in your review settings.

Refactor the unread notification logic to account for the `lastReadAt` timestamp in addition to the `readActivities` list.

This ensures that notifications are correctly marked as read if their `updatedAt` timestamp is before the `lastReadAt` time. The `_isNotificationRead` and `_hasUnreadNotifications` methods have been updated to reflect this improved logic.
@coderabbitai
Copy link

coderabbitai bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Consolidates notification unread/read determination into a private helper _isNotificationRead, adding timestamp-based logic that compares an activity's updatedAt with notificationStatus.lastReadAt and falling back to notificationStatus.readActivities membership. Calls sites (list rendering and _hasUnreadNotifications) now use the helper.

Changes

Cohort / File(s) Summary
Notification Read Detection Refactor
sample_app/lib/screens/user_feed/notification/notification_feed.dart
Adds private helper _isNotificationRead(activity, notificationStatus) centralizing unread/read logic. Replaces direct readActivities containment checks with timestamp comparison against lastReadAt and fallback to readActivities. Updates _hasUnreadNotifications and per-item isUnread usage to call the helper.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through code with careful cheer,
A helper born to make intent clear,
Timestamps checked and lists consulted too,
Now read and unread know just what to do,
Hooray for tidy logic—hoppity hoo! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description addresses the technical changes but lacks required template sections: missing CLA checkbox confirmation, no indication of testing status, no screenshots/videos, and incomplete issue references. Add CLA checkbox confirmation, specify testing approach or mark as not applicable, include optional screenshots showing before/after, and fill in the internal ticket number (FLU-XXXX) and any relevant GitHub issues.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'refactor(samples): improve unread notification logic' clearly and concisely summarizes the main change—improving the unread notification logic by refactoring it.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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 and usage tips.

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.86%. Comparing base (0eed1f9) to head (212e8f8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #88   +/-   ##
=======================================
  Coverage   85.86%   85.86%           
=======================================
  Files         124      124           
  Lines        4300     4300           
=======================================
  Hits         3692     3692           
  Misses        608      608           

☔ View full report in Codecov by Sentry.
📢 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.

@xsahil03x xsahil03x marked this pull request as ready for review January 13, 2026 16:24
@xsahil03x xsahil03x requested a review from a team as a code owner January 13, 2026 16:24
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @sample_app/lib/screens/user_feed/notification/notification_feed.dart:
- Around line 170-186: The function _hasUnreadNotifications is inconsistent with
_isNotificationRead because it uses two separate any() checks that can match
different activities; update _hasUnreadNotifications to determine unreadness
per-activity and return activities.any((it) => !_isNotificationRead(it,
notificationStatus)) or inline the same per-activity logic (not in
notificationStatus.readActivities AND (notificationStatus.lastReadAt == null OR
it.updatedAt.isAfter(lastReadAt))) so each activity is evaluated atomically
using the same criteria as _isNotificationRead.
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 0eed1f9 and 539a6de.

📒 Files selected for processing (1)
  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
🧰 Additional context used
📓 Path-based instructions (1)
**/*.dart

📄 CodeRabbit inference engine (.cursor/rules/cursor-rules-location.mdc)

**/*.dart: Use the barrel_files package with @includeInBarrelFile annotations for public API management in Dart projects; keep implementation details in lib/src/ without annotations
Mark only classes, functions, and enums intended for external package usage with @includeInBarrelFile; keep repository classes, mappers, and internal state objects in lib/src/ without annotations

**/*.dart: Use @freezed mixed mode for data classes in Dart
Return Result<T> from all repository methods in Dart
Apply early return patterns consistently in Dart code
Use pattern matching with switch expressions in Dart
Mark public APIs with @includeInBarrelFile annotation in Dart
Follow enhanced enum vs sealed class guidelines in Dart
Use const constructors where possible in Dart
Implement proper disposal patterns in Dart StateNotifiers and providers
Ensure pure Dart compatibility across VM, Flutter, and Web environments
Plan for StateNotifier reactive patterns when implementing state management in Dart

**/*.dart: Use @freezed for all data classes with required id fields and const constructors
Implement StateNotifier-based reactive state management with automatic change notifications
Apply Result pattern for all async operations with explicit error handling
Use early return patterns for clean control flow in Dart code
Create extension functions for data mapping using .toModel() pattern instead of mapper classes
Mark public APIs with @includeInBarrelFile annotation for barrel file export management
Implement proper resource management with disposal and cleanup patterns in Dart code
Use constructor injection for all dependencies in Dart classes

**/*.dart: All data models should use @freezed with Dart's mixed mode syntax and include @OverRide annotations on fields
Mark classes for public export using @includeInBarrelFile annotation
Use extension functions with .toModel() convention for data mapping instead of dedicated mapper classes
All repository methods must return Result...

Files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
🧠 Learnings (10)
📚 Learning: 2025-12-05T14:37:05.876Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: .cursor/rules/project-overview.mdc:0-0
Timestamp: 2025-12-05T14:37:05.876Z
Learning: Applies to **/*.dart : Implement StateNotifier-based reactive state management with automatic change notifications

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:37:17.519Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: .cursor/rules/stream-feeds-api.mdc:0-0
Timestamp: 2025-12-05T14:37:17.519Z
Learning: Applies to {**/api/**/*.dart,**/*_api.dart,**/client/*.dart} : Stream Feeds API integration should be implemented according to the Activity Streams specification with structured actor, verb, object, and target fields

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/lib/src/state/**/*StateNotifier.dart : Use StateNotifier for reactive state management

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/lib/src/state/**/*StateNotifier.dart : StateNotifier naming convention: Use `*StateNotifier` suffix for StateNotifier implementations (e.g., `FeedStateNotifier`)

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:37:37.953Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: .cursor/rules/stream-feeds-sdk.mdc:0-0
Timestamp: 2025-12-05T14:37:37.953Z
Learning: Applies to **/*.dart : Use StateNotifier for reactive state management with automatic change notifications

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/lib/stream_feeds.dart : Keep public API minimal - most code should be in `lib/src/` internal directory

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/test/**/*.dart : Test through public APIs only, not internal StateNotifier implementations

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:36:55.335Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: .cursor/rules/planit-mode.mdc:0-0
Timestamp: 2025-12-05T14:36:55.335Z
Learning: Applies to **/*.dart : Plan for StateNotifier reactive patterns when implementing state management in Dart

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/lib/src/generated/**/*.dart : Never manually edit generated files (`*.freezed.dart`, `*.g.dart`, `src/generated/`)

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
📚 Learning: 2025-12-05T14:38:02.662Z
Learnt from: CR
Repo: GetStream/stream-feeds-flutter PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-05T14:38:02.662Z
Learning: Applies to packages/stream_feeds/lib/stream_feeds.dart : Follow Effective Dart documentation guidelines for all public APIs

Applied to files:

  • sample_app/lib/screens/user_feed/notification/notification_feed.dart
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (2)
sample_app/lib/screens/user_feed/notification/notification_feed.dart (2)

140-140: LGTM!

Clean delegation to the new helper for determining unread state.


155-168: LGTM!

The helper correctly treats a notification as read if it's explicitly in readActivities or if its updatedAt predates lastReadAt. This consolidates the read-check logic nicely.

@xsahil03x xsahil03x merged commit 344afcf into main Jan 14, 2026
14 of 15 checks passed
@xsahil03x xsahil03x deleted the fix/notifications branch January 14, 2026 09:24
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.

3 participants