Skip to Content
HomeLink Hub
MobileTenant

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

ScreenRouteFileWho sees it
Chats stack/tenant/chats/*app/tenant/chats/_layout.tsxTenants (second icon in the tab bar)
Conversation list/tenant/chatsapp/tenant/chats/index.tsx with components/ChatListItem.tsxTenants
Thread/tenant/chats/[id]app/tenant/chats/[id].tsx with components/ChatHeader.tsxTenants
Notifications/tenant/notificationsapp/tenant/notifications.tsxTenants, 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_TOKEN at 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

  1. Opening the Chats tab mounts useChat(null), which connects the socket to the API host (not the /api/v1 path) with up to 5 reconnection attempts, 2 seconds apart.
  2. On connect the app sets chat.connected to true and emits chat:get_rooms. The backend answers with chat:rooms, and the array is stored in chat.rooms in Redux. No REST request is made; GET /api/v1/chat/rooms exists on chatApi but this screen does not call it.
  3. The header shows Messages, a search box (placeholder Search messages...), a filter icon, and a status line: Connected to chat server or Connecting to chat....
  4. Each room is one row:
Row elementSource
Nameroom.name, else the first participant's first and last name, else Chat room
AvatarFirst participant's avatar, else a generated placeholder image
Previewroom.lastMessage, else Start a new conversation.
TimeHour and minute of lastMessageAt (or createdAt); no date is shown
Green dotShown when the first participant has an avatar
Unread badgeNever shown; the count is hardcoded to 0
  1. While the list is open, a chat:room_updated event updates the preview and time of the matching room in place.
  2. 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

The empty state says 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

The search box and filter icon have no handlers. The green dot is not real presence; it only reflects whether the other participant has a profile photo.

Thread

  1. The screen reads the id route param as the room id, loads the current user id from local:USER (to decide which side a bubble is on) and mounts useChat(roomId).
  2. The hook connects the socket if needed and emits chat:join with the room id. The backend replies with chat:history; the messages are merged into chat.socketMessages[roomId] in Redux, de-duplicated by _id and sorted oldest first.
  3. Header: back chevron, avatar, room name (Chat if the room is not in chat.rooms), a verified tick that is always shown, and a status of Online when the socket is connected or Connecting otherwise. Phone and video icons are present but have no handlers. The red flag icon opens the report sheet.
  4. 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.
  5. 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.
  6. Sending emits chat:message with roomId, content and messageType: "TEXT", then clears the input. There is no optimistic bubble: the message appears when the backend broadcasts chat:message back to the room, which appends it to chat.socketMessages. The backend also emits chat:room_updated to each participant.
  7. Incoming messages arrive on the same chat:message event while the thread is open.
  8. Leaving the screen emits chat:leave and disconnects the socket.

Quick actions: the menu icon inside the composer opens a bottom sheet with three items.

ItemNavigates to
Schedule Inspection/property/inspection
Make Payment/property/payment
Request Documents/property/contract

Quick actions pass no context

These three routes are pushed without any params, so the target screen receives no property id, even though the room has a referencedProperty. Treat them as unfinished shortcuts; the supported entry points are on Property details.

Reporting a chat:

  1. Tap the flag icon. The Report Chat sheet asks Why are you reporting this chat? with five reasons: Spam (preselected), Harassment, Fraud, Inappropriate Content, Other. Exactly one is selected.
  2. Cancel closes the sheet. Submit fires POST /api/v1/chat/rooms/:roomId/report with body reason.
  3. Success closes the sheet and shows the toast Chat Reported / Your report has been submitted for review.
  4. Failure shows the toast Report Failed / Could not submit your report at this time. and leaves the sheet open.

Notifications tab

  1. 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.
  2. The screen fires GET /api/v1/dashboard/recent-activity and keeps the result in the dashboardApi RTK Query cache.
  3. Each activity item is mapped to a card by its type:
Activity typeCard titleDescription
messageAgent MessageThe message text, else ACTOR sent a message about PROPERTY.
bookingEscrow UpdateYour payment for PROPERTY has been updated.
inspectionInspection UpdateACTOR updated PROPERTY.
reviewNew Property MatchACTOR updated PROPERTY.
anything elseSecurity AlertThe item text, else A security-related update was received.
  1. Cards are sorted newest first and grouped under TODAY, YESTERDAY and EARLIER. Time is relative: 5m ago, 3hr ago, 2d ago.
  2. 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.
  3. Read state is stored on the device in the AsyncStorage key tenant_notifications_read_map_v1 (no session: or local: prefix), as a map of card id to true. The card id is built from the type, time and actor.
  4. Settings in the header opens /tenant/profile/notifications. See Profile and settings.
  5. 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… with Waiting for the chat connection. This usually takes a moment.
  • List, connected and no rooms: No Conversations Yet with Start 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:error events 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 Yet with Updates 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

Every 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_updated for 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.rooms and chat.socketMessages.

On this page