Chats and Notifications
The tenant conversation list, the message thread over the chat socket, reporting a chat, and the in-app notifications screen.
Chat on the mobile app runs over a Socket.IO connection rather than REST. The notifications screen is a separate, read-only feed built from the dashboard activity endpoint.
Where it lives
| Screen | Route | File | Who sees it |
|---|---|---|---|
| Chats stack | /tenant/chats/* | app/tenant/chats/_layout.tsx | Tenants (second icon in the tab bar) |
| Conversation list | /tenant/chats | app/tenant/chats/index.tsx with components/ChatListItem.tsx | Tenants |
| Thread | /tenant/chats/[id] | app/tenant/chats/[id].tsx with components/ChatHeader.tsx | Tenants |
| Notifications | /tenant/notifications | app/tenant/notifications.tsx | Tenants, from the bell on the home screen |
Supporting code: hooks/use-chat.ts (socket lifecycle and events), services/chat/socket.service.ts (the single socket instance), services/chat/chat-slice.ts (Redux slice chat), services/chat/chat-api.ts (RTK Query slice chatApi), services/dashboard/dashboard-api.ts (getRecentActivity).
Before you start
- Signed in. The socket handshake sends the access token read from
session:ACCESS_TOKENat the moment the socket is created. - No KYC is required.
- No device permission is needed to use these screens. Push notification permission and token registration are covered in App launch and onboarding.
- A conversation must already exist for the user. See the warning under the conversation list.
Flow
Conversation list
- Opening the Chats tab mounts
useChat(null), which connects the socket to the API host (not the/api/v1path) with up to 5 reconnection attempts, 2 seconds apart. - On
connectthe app setschat.connectedto true and emitschat:get_rooms. The backend answers withchat:rooms, and the array is stored inchat.roomsin Redux. No REST request is made;GET /api/v1/chat/roomsexists onchatApibut this screen does not call it. - The header shows
Messages, a search box (placeholderSearch messages...), a filter icon, and a status line:Connected to chat serverorConnecting to chat.... - Each room is one row:
| Row element | Source |
|---|---|
| Name | room.name, else the first participant's first and last name, else Chat room |
| Avatar | First participant's avatar, else a generated placeholder image |
| Preview | room.lastMessage, else Start a new conversation. |
| Time | Hour and minute of lastMessageAt (or createdAt); no date is shown |
| Green dot | Shown when the first participant has an avatar |
| Unread badge | Never shown; the count is hardcoded to 0 |
- While the list is open, a
chat:room_updatedevent updates the preview and time of the matching room in place. - Tapping a row pushes the thread with the room
_id.
Row tap goes to the wrong route group
ChatListItem pushes /chats/ROOM_ID, not /tenant/chats/ROOM_ID. Because /tenant is a real path segment and (tabs) is a route group, that path resolves to app/(tabs)/chats/[id].tsx, the agent-side copy of the thread screen under the agent tab layout. The two thread files are near-identical, so the conversation still works, but the tenant tab bar is not the one on screen. Push notification taps do use /tenant/chats/ROOM_ID. Verify on a device before relying on either path.No way to start a chat from the app
Start a chat from any property and it will show up here. and use-chat.ts exposes createAndSend (socket event chat:create_and_send with propertyId), but no screen calls it; the message button on property details is a stub. Rooms appear here only if they were created elsewhere, for example on the web app.List controls that are placeholders
Thread
- The screen reads the
idroute param as the room id, loads the current user id fromlocal:USER(to decide which side a bubble is on) and mountsuseChat(roomId). - The hook connects the socket if needed and emits
chat:joinwith the room id. The backend replies withchat:history; the messages are merged intochat.socketMessages[roomId]in Redux, de-duplicated by_idand sorted oldest first. - Header: back chevron, avatar, room name (
Chatif the room is not inchat.rooms), a verified tick that is always shown, and a status ofOnlinewhen the socket is connected orConnectingotherwise. Phone and video icons are present but have no handlers. The red flag icon opens the report sheet. - Messages: the user's own bubbles sit on the right with a double-tick icon; the other participant's sit on the left. Each shows the time as hour and minute. Avatars are not rendered.
- Composer: a multiline input (placeholder
Type a message...). The send button is disabled until the text has a non-whitespace character. The paperclip and microphone icons have no handlers. - Sending emits
chat:messagewithroomId,contentandmessageType: "TEXT", then clears the input. There is no optimistic bubble: the message appears when the backend broadcastschat:messageback to the room, which appends it tochat.socketMessages. The backend also emitschat:room_updatedto each participant. - Incoming messages arrive on the same
chat:messageevent while the thread is open. - Leaving the screen emits
chat:leaveand disconnects the socket.
Quick actions: the menu icon inside the composer opens a bottom sheet with three items.
| Item | Navigates to |
|---|---|
Schedule Inspection | /property/inspection |
Make Payment | /property/payment |
Request Documents | /property/contract |
Quick actions pass no context
referencedProperty. Treat them as unfinished shortcuts; the supported entry points are on Property details.Reporting a chat:
- Tap the flag icon. The
Report Chatsheet asksWhy are you reporting this chat?with five reasons:Spam(preselected),Harassment,Fraud,Inappropriate Content,Other. Exactly one is selected. Cancelcloses the sheet.SubmitfiresPOST /api/v1/chat/rooms/:roomId/reportwith bodyreason.- Success closes the sheet and shows the toast
Chat Reported/Your report has been submitted for review. - Failure shows the toast
Report Failed/Could not submit your report at this time.and leaves the sheet open.
Notifications tab
- Tap the bell on the home screen to open
/tenant/notifications. A cold start or tap on a push notification that is not a chat message also lands here. - The screen fires
GET /api/v1/dashboard/recent-activityand keeps the result in thedashboardApiRTK Query cache. - Each activity item is mapped to a card by its
type:
Activity type | Card title | Description |
|---|---|---|
message | Agent Message | The message text, else ACTOR sent a message about PROPERTY. |
booking | Escrow Update | Your payment for PROPERTY has been updated. |
inspection | Inspection Update | ACTOR updated PROPERTY. |
review | New Property Match | ACTOR updated PROPERTY. |
| anything else | Security Alert | The item text, else A security-related update was received. |
- Cards are sorted newest first and grouped under
TODAY,YESTERDAYandEARLIER. Time is relative:5m ago,3hr ago,2d ago. - An unread card shows a dot. Tapping a card marks it read and removes the dot. Nothing else happens on tap: there is no navigation to the chat, booking or property.
- Read state is stored on the device in the AsyncStorage key
tenant_notifications_read_map_v1(nosession:orlocal:prefix), as a map of card id totrue. The card id is built from the type, time and actor. Settingsin the header opens/tenant/profile/notifications. See Profile and settings.- Pull down to refetch.
The feed is the agent activity endpoint
GET /api/v1/dashboard/recent-activity was written for agents: inspections, bookings and reviews are looked up on properties the caller owns or manages. A tenant owns none, so in practice the tenant feed contains only message items from their chat rooms, capped at the five most recent rooms. There is no dedicated notification store, and read state is device-only: it is not shared across devices, not scoped per user, and not cleared on sign-out.States and edge cases
- List, socket not connected and no rooms: empty state titled
Connecting…withWaiting for the chat connection. This usually takes a moment. - List, connected and no rooms:
No Conversations YetwithStart a chat from any property and it will show up here. - Socket errors and failed reconnects are only logged to the console. After 5 failed attempts the list stays on
Connecting to chat...with no retry button. - Backend
chat:errorevents are not listened for, so a rejected join or send fails silently. - The token is captured once when the socket is created. A token refreshed later is not pushed to an existing socket.
- Notifications loading: spinner with
Loading notifications.... Empty:No Notifications YetwithUpdates about your properties, escrow payments and messages will appear here.A failed request also shows the empty state; there is no error view.
Returning from a thread drops the list connection
useChat consumer disconnects the shared socket on unmount. Going back from a thread therefore disconnects the socket the list is still listening on; the list flips to Connecting to chat... and does not reconnect until the Chats screen itself remounts. This is from reading the code and should be confirmed on a device.What happens next
- A sent message is persisted by the backend and delivered to other participants in the room over the socket; participants not in the room receive
chat:room_updatedfor their list. - A report is stored by the backend for review. Nothing changes in the thread afterwards.
- On sign-out or session expiry the Redux store is reset, which empties
chat.roomsandchat.socketMessages.