Skip to content

Type Deep Dive — Runtime Workspace And Unread

1. Detail workspace hiện là shell mỏng

ConversationDetail chỉ làm 3 việc:

  1. nhận id từ route,
  2. truyền conversationId vào Conversation,
  3. giữ RouterView cho nhánh con (ConversationDetail.tsx:22).

Nó có handleVideoCall() để push sang ROUTE_CONVERSATION_CONFERENCE, nhưng việc này mới chỉ là intent ở page layer.

2. Header workspace chưa phát video event

Conversation component:

  • nhận prop theo useConversationMessagesProps,
  • emit "video",
  • render QBtn icon camera,
  • nhưng button không có onClick nào (Conversation/index.tsx:23).

Nghĩa là ConversationDetail có truyền onVideo={handleVideoCall}, nhưng Conversation hiện không phát sự kiện này.

3. Conversation list có unread/read intent nhưng chưa chạy được

Điều list đang cố làm

Hành viSource
click item -> update conversation_member.read_at của user hiện tạiConversationList.tsx:57
sau đó emit select(item.id)ConversationList.tsx:79
infinite scroll với offset, debounce, onLoadConversationList.tsx:116
unread badge cap ở 9+ConversationList.tsx:168

Vấn đề

useUpdateConversationMembersMutation() ở cuối file chỉ:

throw new Error("Function not implemented.")

(ConversationList.tsx:188)

Do đó mọi click item có khả năng làm vỡ runtime ngay tại FE, trừ khi compile/build tree somehow tree-shake path này ngoài runtime.

4. Message stream có render nhưng chưa có send path

ConversationMessages đã có:

  • reverse infinite scroll,
  • map msg.user_id -> user,
  • relative time cho message mới,
  • composer với QForm + QInput + send button.

Nhưng handleChatEnter() hiện chỉ:

  1. check chatMessage.value,
  2. return luôn (ConversationMessages.tsx:92).

Không có mutation, không có store update optimistic, không có provider send path.

5. Store và merge logic

useConversationStore

ActionVai trò
updateConversations(items)merge theo id, sort theo last_message_created_at
updateConversationCursor(items)giữ cursor cũ nhất của batch conversations
updateConversationMessages(messages)group theo conversation_id rồi merge từng group
addConversationCursor(data)helper gộp list + cursor

Utility merge message

mergeSortedConversationMessages() không append mù. Nó so sánh created_at, tạo left/middle/right segments và tránh duplicate theo id (utils.ts:1). Đây là điểm đáng giữ vì nó phản ánh design intent cho streaming/pagination dù shell FE còn thiếu.

6. Findings kỹ thuật

IDMức độMô tả
RW-F01CaoConversation không emit video event vì QBtn chưa có onClick, làm page-level handler vô dụng (Conversation/index.tsx:23).
RW-F02CaoConversationList dùng mutation stub và có thể nổ runtime ngay khi user click item (ConversationList.tsx:188).
RW-F03CaoComposer trong ConversationMessages không gửi message thật; UI đang tạo kỳ vọng sai về khả năng chat realtime (ConversationMessages.tsx:92).
RW-F04Trung bìnhuseConversation.ts rỗng và ConversationProvider pass-through, cho thấy module chưa có orchestration layer đủ trưởng thành (useConversation.ts:1, ConversationProvider.tsx:12).