fix(web): code review round 1 -- messaging UI critical/high findings
- CRITICAL: draft text and voice-recording state were never isolated per conversation. ConversationView is one long-lived instance reused across every topic (`:topicId` route param change doesn't remount it), so a single `draft` string leaked one conversation's unsent text into whatever conversation was opened next -- and, far more seriously, starting a voice recording in conversation A and then switching to conversation B before hitting send would publish that recording into B: VoiceRecorder keeps its own MediaRecorder running across the switch, but the onSend callback passed to it is a fresh closure over whatever topic is CURRENT when it finally fires. Fixed by keying drafts per topicId and force- resetting `recording` (unmounting VoiceRecorder, which stops its stream) whenever topicId changes. - CRITICAL: the detail/settings panel was completely unreachable below 960px -- it only ever rendered inside `lg:block` (>=1280px, docked) or `md:block lg:hidden` (960-1279px, drawer) wrappers, so tapping the header "i" button below 960px flipped internal state and fired its data queries with zero visible effect. Added the README §1.4-mandated <960px full-page overlay tier, and a small new useMediaQuery hook so the header's "i" button highlight reflects whether the panel is ACTUALLY visible right now instead of being hardcoded to a breakpoint (it was previously always blue at 960-1279px regardless of the drawer's real open state, and always grey at >=1280px despite the panel being permanently docked open there). - CRITICAL (visually confirmed against 1a-desktop-chat.png): messages you send never showed an avatar at all (just an empty spacer) -- every reference screenshot shows your own "我" avatar beside your bubbles the same as the other party's. MessageRow now takes myUserId and renders it. While in there, also moved the failed-send error icon beside the bubble (README: "气泡左侧") instead of below it with the retry text. - CRITICAL: ChatListColumn's search box had no value/onChange at all -- typing into it did nothing. Now filters by contact name; added the search_off/"未找到相关会话" and forum/"暂无会话" empty states README §2.1 calls for, neither of which existed before. - MEDIUM (real Tailwind cascade bug): the selected chat-list row's highlight was being overridden by the unconditional `hover:bg-[...]` class on the same element -- Tailwind emits hover-variant rules after base rules regardless of source order, so hovering an already-selected row visually un-selected it until the mouse moved away. Scoped the hover class to the non-selected branch only. - NavRail: inactive icons used the wrong color token (icon-default #555c65 instead of the spec's #656b74, this app's text-secondary); the unread badge prop was never actually supplied by AppShell, so the badge's otherwise-pixel-correct rendering never appeared in the running app. Fixed both, and gave BottomTabBar's 消息 tab the same real badge (computed once in AppShell from useChatList(), passed to both). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
569f266390
commit
a7da4dc079
@@ -5,6 +5,7 @@ import { Outlet, useParams } from 'react-router-dom';
|
||||
import { ChatListColumn } from '@/features/messages/ChatListColumn';
|
||||
import { DetailColumn } from '@/features/messages/DetailColumn';
|
||||
import { OfflineBanner } from '@/features/messages/OfflineBanner';
|
||||
import { useMediaQuery } from '@/lib/hooks';
|
||||
import { useChatList } from '@/lib/tinode/hooks';
|
||||
|
||||
/**
|
||||
@@ -14,13 +15,21 @@ import { useChatList } from '@/lib/tinode/hooks';
|
||||
* provide one at this tier -- see ConversationView).
|
||||
* - 960-1279: list + main together, detail as an overlay drawer toggled by the header's "i" icon.
|
||||
* - >=1280: list + main + detail all docked side by side.
|
||||
* Below 960px (both the two-column and single-column tiers), the detail panel instead pushes as a
|
||||
* full-page overlay -- README §1.4's "详情/设置等作为整页推入" convention -- since there's no room
|
||||
* to dock or drawer it in without covering the conversation entirely anyway.
|
||||
*/
|
||||
export function MessagesLayout() {
|
||||
const { topicId } = useParams();
|
||||
const [detailOpen, setDetailOpen] = useState(false);
|
||||
const isDocked = useMediaQuery('(min-width: 1280px)');
|
||||
const showListOnNarrow = !topicId;
|
||||
const contacts = useChatList();
|
||||
const peerName = contacts.find((c) => c.topic === topicId)?.public?.fn || topicId || '';
|
||||
// The "i" button should read as active whenever the detail panel is actually visible right now --
|
||||
// always true when docked (>=1280px, no close affordance), otherwise whatever the drawer/full-page
|
||||
// toggle state is. Previously hardcoded to the breakpoint itself instead of this real state.
|
||||
const detailVisible = isDocked || detailOpen;
|
||||
|
||||
return (
|
||||
<div className="relative flex h-full w-full">
|
||||
@@ -32,7 +41,7 @@ export function MessagesLayout() {
|
||||
<ChatListColumn />
|
||||
</div>
|
||||
<div className={`h-full min-w-0 flex-1 ${showListOnNarrow ? 'hidden md:block' : ''}`}>
|
||||
<Outlet context={{ onToggleDetail: () => setDetailOpen((v) => !v) }} />
|
||||
<Outlet context={{ onToggleDetail: () => setDetailOpen((v) => !v), detailVisible }} />
|
||||
</div>
|
||||
</div>
|
||||
{topicId ? (
|
||||
@@ -48,6 +57,11 @@ export function MessagesLayout() {
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
{detailOpen && topicId ? (
|
||||
<div className="fixed inset-0 z-30 bg-white md:hidden">
|
||||
<DetailColumn topicId={topicId} peerName={peerName} onClose={() => setDetailOpen(false)} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user