fix(messages-ui): surface silent send failures, stop scroll/render churn (+cleanup)
- ChatThread send had no onError: a 404 (recipient gone) or 429 (rate-limited) send failed silently (api.req shows no modal for those "caller-handled" statuses). Added onError → toast for 404/429 (400/409/500 already raise the global dialog); draft is kept for retry. New trilingual messages.sendFailed key. - ChatThread scroll-to-bottom effect keyed on `plain` too, so every 20s poll's decrypt pass yanked a scrolled-up reader back to the bottom. Key on items.length. - ChatThread + Messages decrypt effects keyed on `items` (a fresh `?? []` array every render) → a render storm while loading. Key on q.dataUpdatedAt. - chatDock.ts: use LS.chatDock(userId) instead of the bare "siftlode.chatDock.*" literal (matches the storage LS registry). tsc green, re-review clean, localdev boots, Messages renders (locked-state) w/o console errors.
This commit is contained in:
parent
40ddaa2c92
commit
5441ad203d
6 changed files with 31 additions and 7 deletions
|
|
@ -64,12 +64,15 @@ function ConversationList({
|
|||
const items = q.data?.items ?? [];
|
||||
const [previews, setPreviews] = useState<Record<number, string>>({});
|
||||
|
||||
// Decrypt conversation previews when fresh data arrives. Keyed on dataUpdatedAt (not `items`):
|
||||
// the `?? []` fallback is a new array each render, which would otherwise spin this effect
|
||||
// (and setPreviews) every render while the query is loading.
|
||||
useEffect(() => {
|
||||
if (!ready) return;
|
||||
let cancelled = false;
|
||||
(async () => {
|
||||
const out: Record<number, string> = {};
|
||||
for (const c of items) {
|
||||
for (const c of q.data?.items ?? []) {
|
||||
const m = c.last_message;
|
||||
if (m.kind === "user" && m.ciphertext && m.iv) {
|
||||
try {
|
||||
|
|
@ -85,7 +88,8 @@ function ConversationList({
|
|||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [items, ready]);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [q.dataUpdatedAt, ready]);
|
||||
|
||||
function previewText(c: Conversation): string {
|
||||
const m = c.last_message;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue