The Messaging tab is the direct communication channel between a coach and every athlete on their roster. From a single consolidated hub, coaches can see all active conversations in a sidebar, pick up any thread instantly, and exchange messages that are persisted in Firestore under theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/piratta/gymApp/llms.txt
Use this file to discover all available pages before exploring further.
fit_messages collection. Whether a quick check-in before a session or a detailed form-check debrief after a review, every interaction stays in one organised place — no external apps required.
Message Data Model
Each message exchanged in FocusFlow is represented by theMessage interface:
| Field | Description |
|---|---|
senderId | User.id of the author — either the coach or the athlete. |
receiverId | User.id of the recipient. |
content | Plain-text message body. |
timestamp | ISO 8601 string written at send time. |
isRead | false until the recipient opens the conversation thread. |
Conversation List
The chat sidebar renders one entry per athlete registered under the coach’s account. Each entry shows:Unread Badge
A red badge showing the unread message count appears on any conversation with messages where
isRead: false and receiverId === coach.id. The dashboard KPI card also surfaces the total “Chats sin responder” count.Mark as Read
Clicking a conversation sets it as the active thread. A “Quitar notificaciones” button appears in the chat header whenever unread incoming messages are present, and calling
onMarkMessagesRead(clientId) marks all of them as read.Message Delivery
FocusFlow syncs messages via a background polling loop that runs every 10 seconds while a user is logged in. When new messages arrive for the current user, the app:- Updates the local message state and
localStorage(fit_messages). - Plays an audio chime via the Web Audio API (
playNotificationSound). - Fires a browser push notification (
sendBrowserNotification) if the user has previously granted theNotificationpermission.
Message History
All conversations are stored persistently in Firestore under thefit_messages collection key. When a coach opens any conversation, the full message history is loaded — there is no pagination limit on the visible thread. This ensures coaches can always scroll back to reference previous guidance, agreed-upon plans, or athlete feedback without losing context.
Open the Messages tab
Navigate to the Messages tab in the Coach Dashboard top navigation bar. The unread count badge is shown directly on the tab icon.
Select an athlete conversation
Click any athlete entry in the conversation sidebar. The full thread loads immediately.
Send a message
Type in the message input field at the bottom of the thread and press Send (or hit Enter). The message is written to Firestore and the recipient’s poller picks it up within 10 seconds.
Notifications
New incoming messages trigger both in-app and browser push notifications, using thetriggerNotification function from src/lib/notifications.ts.
AppNotification produced carries linkTab: "messages", so tapping the notification banner navigates directly to the coach’s Messages tab. Notifications also:
- Play an audio chime via the Web Audio API (
playNotificationSound). - Fire a browser push notification (
sendBrowserNotification) if the user has previously granted theNotificationpermission.