Add timestamp-based last-read tracking and unread divider markers#227
Add timestamp-based last-read tracking and unread divider markers#227Specter242 wants to merge 3 commits intozjs81:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ccfe97278
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (markerIndex >= 0) return markerIndex; | ||
| return null; | ||
| } |
There was a problem hiding this comment.
Fall back to unread count when marker scan finds nothing
When a last-read marker exists, this branch returns null if no message timestamp is greater than the marker, so the count-based fallback is never used. Because markContactRead/markChannelRead store DateTime.now() while incoming message timestamps are device-provided, clock skew or unset device time can leave unread messages with timestamps <= marker; in that case unread counts stay positive but first-unread positioning is lost (same logic is duplicated in firstUnreadChannelIndex).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 048b798.\n\nI updated both firstUnreadContactIndex and firstUnreadChannelIndex to always fall back to unread-count positioning when a timestamp marker exists but no message is newer than that marker. This keeps first-unread placement working under clock skew / device-time mismatch cases while still preferring marker-based placement when available.
048b798 to
724b760
Compare
Summary
Adds timestamp-based last-read tracking for contacts/channels and uses it to place an in-chat unread divider for DM and channel threads.
Why
Unread counts alone are not stable for locating the unread boundary after list mutations.
Timestamp markers provide deterministic first-unread positioning while preserving count-based fallback behavior.
Changes
lib/storage/unread_store.dartlib/connector/meshcore_connector.dartcontactLastReadTimestamp(...)channelLastReadTimestamp(...)firstUnreadContactIndex(...)firstUnreadChannelIndex(...)lib/screens/chat_screen.dartlib/screens/channel_chat_screen.dartlib/widgets/unread_marker_divider.dartBehavior Notes
Validation
dart formaton touched filesflutter analyze lib/connector/meshcore_connector.dart lib/storage/unread_store.dart lib/screens/chat_screen.dart lib/screens/channel_chat_screen.dart lib/widgets/unread_marker_divider.dart(pass)Issue
Part of #73