Skip to content

Auto-open unread group threads from friends - #12

Merged
AugusDogus merged 1 commit into
mainfrom
feature/auto-open-unread-groups
Mar 28, 2026
Merged

Auto-open unread group threads from friends#12
AugusDogus merged 1 commit into
mainfrom
feature/auto-open-unread-groups

Conversation

@AugusDogus

@AugusDogus AugusDogus commented Mar 27, 2026

Copy link
Copy Markdown
Owner

Summary

  • Passes an autoOpenUnread flag when opening a group from the Friends screen if that group has unread messages.
  • Auto-opens the first unread group thread in the Group screen once data has loaded, guarding against повторed opens.
  • Excludes group messages from friend-row unread calculations and message-status queries so friend-facing counts stay scoped to direct messages.
  • Extends navigation types to accept the new autoOpenUnread route param.

Testing

  • Not run
  • Verified the change set updates navigation, inbox loading behavior, and unread-count queries consistently across app and API layers
  • Not run: unit/integration tests

Summary by CodeRabbit

  • New Features

    • Groups with unread messages now automatically display the unread messages view when selected from your friends list, streamlining navigation.
  • Bug Fixes

    • Group messages no longer incorrectly count toward individual sender unread message totals.
    • Message delivery status queries now properly exclude group message deliveries.

- Pass unread state into Group navigation
- Open the viewer automatically for unread group inboxes
- Exclude group deliveries from friend row/status calculations
@vercel

vercel Bot commented Mar 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
whisp Ready Ready Preview, Comment Mar 27, 2026 4:44am

Request Review

@coderabbitai

coderabbitai Bot commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2dd4ec67-c62f-40fb-b055-4bcf3c829f01

📥 Commits

Reviewing files that changed from the base of the PR and between b69d7ff and fadf874.

📒 Files selected for processing (5)
  • apps/expo/src/app/friends.tsx
  • apps/expo/src/app/group.tsx
  • apps/expo/src/hooks/useFriendRows.ts
  • apps/expo/src/navigation/types.ts
  • packages/api/src/services/message-status.ts

Walkthrough

This change introduces automatic message viewer opening when navigating to a group with unread messages. The FriendsScreen now passes an autoOpenUnread parameter during navigation; the GroupScreen reads this parameter and triggers the message viewer if conditions are met. Additionally, group deliveries are excluded from message-status queries in the API layer.

Changes

Cohort / File(s) Summary
Route Navigation Enhancement
apps/expo/src/app/friends.tsx, apps/expo/src/app/group.tsx, apps/expo/src/navigation/types.ts
Added autoOpenUnread route parameter. FriendsScreen passes true when navigating to a group with unread count. GroupScreen reads the parameter and conditionally triggers openViewer() on mount via useEffect with a ref guard to prevent repeated opens.
Message Status Query Filtering
packages/api/src/services/message-status.ts
Updated three exported functions (getPendingSentDeliveries, getLastSentMimeTypes, getLastReceivedMimeTypes) to exclude deliveries with non-null groupId via isNull() filter in where clauses.
Friend Row Message Counting
apps/expo/src/hooks/useFriendRows.ts
Modified unread message tracking to skip inbox entries where m.groupId is set, affecting unreadCount, hasUnread, and timestamp/mime type computations for friend rows.

Sequence Diagram

sequenceDiagram
    actor User
    participant FriendsScreen
    participant Navigation
    participant GroupScreen
    participant MessageViewer

    User->>FriendsScreen: Press group row with unread
    FriendsScreen->>FriendsScreen: Check group.unreadCount > 0
    FriendsScreen->>Navigation: Navigate to "Group" route<br/>{groupId, autoOpenUnread: true}
    Navigation->>GroupScreen: Mount with route params
    GroupScreen->>GroupScreen: Read autoOpenUnread from params
    GroupScreen->>GroupScreen: useEffect: Check conditions<br/>(autoOpenUnread, !isLoading, inboxRaw.length)
    alt Conditions Met & Not Already Opened
        GroupScreen->>MessageViewer: Call openViewer(inboxRaw, 0)
        MessageViewer->>User: Display unread messages
    else
        GroupScreen->>User: Render group without auto-open
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 When groups arrive with messages unread,
The drawer springs open, as needs are fed,
Auto-opens the threads with hoppy delight,
No more searching—the inbox burns bright! 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: auto-opening unread group threads when navigating from the Friends screen. It is clear, concise, and directly reflects the core functionality added across multiple files.

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


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.

@AugusDogus
AugusDogus merged commit f5f7de0 into main Mar 28, 2026
6 checks passed
@AugusDogus
AugusDogus deleted the feature/auto-open-unread-groups branch March 28, 2026 19:57
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