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
| Route | View / component file | Access |
|---|---|---|
/app/property/:id/message | src/views/app/message-agent.tsx | signed-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
- Click Message Agent on a listing. The page opens and the socket connects.
- On connect the app emits
chat:get_rooms. The server answers withchat:rooms, the user's conversations, which are stored inchat.rooms. - The page looks for a room whose referenced property matches the listing id.
- Found: it emits
chat:joinwithroomId, the server answers withchat:history, and the messages are merged intochat.socketMessagesin date order. - Not found: the page shows the empty state and waits for the first message.
- Found: it emits
- 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
- 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.
- First message on a listing (no room yet): the app emits
chat:create_and_sendwithpropertyId,contentandmessageType: "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. - Existing conversation: the message is added to the list immediately with a temporary id, then the app emits
chat:messagewithroomId,contentandmessageType: "TEXT". When the server echoes the saved message, it replaces the temporary one (matched on identical text). - 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:typingwithroomIdandisTyping: true, and automatically sendsfalseafter 2 seconds without input. - When the other side is typing, three animated dots appear at the bottom of the list.
- Incoming
chat:messageevents are appended live.chat:room_updatedupdates the room's last-message preview in the store. - Leaving the page emits
chat:leaveand disconnects the socket.
Socket events used on this page:
| Direction | Event | Payload or purpose |
|---|---|---|
| emit | chat:get_rooms | Ask for the user's rooms |
| emit | chat:join / chat:leave | roomId |
| emit | chat:create_and_send | propertyId, content, messageType |
| emit | chat:message | roomId, content, messageType |
| emit | chat:typing | roomId, isTyping |
| receive | chat:rooms | Room list |
| receive | chat:history | roomId and its messages |
| receive | chat:message | One new message |
| receive | chat:typing | roomId, userId, username, isTyping |
| receive | chat:room_updated | roomId, 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:historyis 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.
HomeLink Hub