Skip to Content
HomeLink Hub
Tenant Web App

Messages

Chatting with a listing's agent or landlord in real time from the property's message page.

Messaging in the tenant web app is always tied to one listing. Each listing has one conversation between the tenant and its lister, opened from the listing's message page. Everything runs over the Socket.IO connection; no REST call is made on this screen.

Where it lives

RouteView / component fileAccess
/app/property/:id/messagesrc/views/app/message-agent.tsxsigned-in

Supporting code: src/hooks/use-chat.ts (socket wiring), src/services/chat/chat-slice.ts (Redux chat slice) and src/services/chat/socket.service.ts (the shared socket).

There is no inbox

This app has no page that lists all conversations. A chat can only be reached from its listing: Message Agent on the property page and on My Properties, and Message Owner or Secure Support Chat on the escrow tracking page.

Before you start

  • Signed in, so the socket can authenticate with the stored token.
  • The listing id in the URL is what links the conversation to a property.

Flow

Open a conversation

  1. Click Message Agent on a listing. The page opens and the socket connects.
  2. On connect the app emits chat:get_rooms. The server answers with chat:rooms, the user's conversations, which are stored in chat.rooms.
  3. The page looks for a room whose referenced property matches the listing id.
    • Found: it emits chat:join with roomId, the server answers with chat:history, and the messages are merged into chat.socketMessages in date order.
    • Not found: the page shows the empty state and waits for the first message.
  4. The header shows the other participant's name (just "Agent" until a room exists), a Verified badge, "Property Consultant" and an Online / Offline dot. Once a room exists, a pill under the header shows the listing's title and price.

Send a message

  1. Type in the box ("Type a message... (Enter to send)"). Enter sends; Shift+Enter adds a new line. The send button is disabled while the box is empty or only whitespace.
  2. First message on a listing (no room yet): the app emits chat:create_and_send with propertyId, content and messageType: "TEXT". The server creates the room and sends the message in one step; the bubble appears when the server sends back the room and message.
  3. Existing conversation: the message is added to the list immediately with a temporary id, then the app emits chat:message with roomId, content and messageType: "TEXT". When the server echoes the saved message, it replaces the temporary one (matched on identical text).
  4. The list scrolls to the newest message. The user's own messages are aligned to one side and the other person's to the other, each with a time.

Typing indicator and live updates

  • While typing, the app emits chat:typing with roomId and isTyping: true, and automatically sends false after 2 seconds without input.
  • When the other side is typing, three animated dots appear at the bottom of the list.
  • Incoming chat:message events are appended live. chat:room_updated updates the room's last-message preview in the store.
  • Leaving the page emits chat:leave and disconnects the socket.

Socket events used on this page:

DirectionEventPayload or purpose
emitchat:get_roomsAsk for the user's rooms
emitchat:join / chat:leaveroomId
emitchat:create_and_sendpropertyId, content, messageType
emitchat:messageroomId, content, messageType
emitchat:typingroomId, isTyping
receivechat:roomsRoom list
receivechat:historyroomId and its messages
receivechat:messageOne new message
receivechat:typingroomId, userId, username, isTyping
receivechat:room_updatedroomId, lastMessage, lastMessageAt

States and edge cases

  • Empty. "No messages yet. Say hello!"
  • Disconnected. A small no-signal icon appears beside the name and the dot reads Offline. The socket retries up to 5 times, 2 seconds apart. The message box stays enabled; messages sent while offline are not queued by this code.
  • No send failure feedback. There are no toasts or retry controls. If the server never echoes a message, a temporary bubble simply stays as it is.
  • Signed out. The page still renders, but the socket has no token, so no rooms or history arrive and sent messages go nowhere.
  • Back to property returns to /app/property/:id.
  • History length. Whatever the server sends in chat:history is shown; there is no "load older messages" control.

Static and unfinished elements

The Online / Offline dot reflects the tenant's own socket connection, not whether the agent is online. The Verified badge and "Property Consultant" title are fixed text for every conversation. The phone and website icons in the header are placeholder links, and the paperclip and image buttons have no handlers, so only text can be sent. The footer line "Messages are end-to-end encrypted by Homelink Hub" is a static label; nothing in this app's code encrypts messages.

Leaving the chat drops the shared socket

The whole app shares one socket. This page disconnects and discards it on leave (the escrow tracking page does the same), which also removes the live-notification listener that was attached at app start. Live notifications then stop until the next full page load. See Notifications.

REST chat endpoints are defined but unused

src/services/chat/chat-api.ts defines GET /api/v1/chat/rooms/:roomId/messages, POST /api/v1/chat/rooms, POST /api/v1/chat/rooms/:roomId/messages and DELETE /api/v1/chat/messages/:messageId. No screen in this app calls them, so there is no message deletion in the UI.

What happens next

The message is delivered to the lister through the same chat rooms their own app reads. Whether the lister also gets a push or email is decided on the backend and by their notification preferences; this app's code does not show it. On the tenant side, a new message can arrive as a messages notification, see Notifications.

On this page