From 36e697613b28647bcf76a2f2d323e67be7db67be Mon Sep 17 00:00:00 2001 From: Lotus CI Date: Fri, 16 Oct 2026 22:25:41 -0400 Subject: [PATCH] fix(messages): the delivery indicator updates when a send completes (#306) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DeliveryStatus showed whatever mEvent.status was at the last timeline re-render, and a local echo's status changes (SENDING → SENT → confirmed, NOT_SENT → retried) only emit event-level events, so the last message in a quiet room kept "Sending..." (or a stale "Failed to send. Click to retry" after an outbox retry) indefinitely. It now re-renders on MatrixEventEvent.Status / LocalEventIdReplaced. Not browser-verified in this change (checks: tsc, unit tests, eslint). Fixes #306 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_017PCb59uY3UKqDqt7B6hzd5 --- src/app/features/room/message/Message.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/features/room/message/Message.tsx b/src/app/features/room/message/Message.tsx index ec7f52490..9fc1c83d4 100644 --- a/src/app/features/room/message/Message.tsx +++ b/src/app/features/room/message/Message.tsx @@ -31,12 +31,13 @@ import React, { MouseEventHandler, ReactNode, useCallback, + useEffect, useRef, useState, } from 'react'; import FocusTrap from 'focus-trap-react'; import { useHover, useFocusWithin } from 'react-aria'; -import { MatrixEvent, Room, EventStatus } from 'matrix-js-sdk'; +import { MatrixEvent, MatrixEventEvent, Room, EventStatus } from 'matrix-js-sdk'; import { Relations } from 'matrix-js-sdk/lib/models/relations'; import classNames from 'classnames'; import { useAtom, useAtomValue } from 'jotai'; @@ -114,6 +115,20 @@ function DeliveryStatus({ }) { const mx = useMatrixClient(); const offline = useAtomValue(sendOfflineAtom); + // [Gitea #306] A local echo's status changes (SENDING → SENT → confirmed, + // NOT_SENT → retried) don't re-render the timeline, so the last message in a + // quiet room kept "Sending..." (or a stale "Failed to send") indefinitely. + // Re-render on the event's own status updates. + const [, setStatusTick] = useState(0); + useEffect(() => { + const bump = () => setStatusTick((t) => t + 1); + mEvent.on(MatrixEventEvent.Status, bump); + mEvent.on(MatrixEventEvent.LocalEventIdReplaced, bump); + return () => { + mEvent.off(MatrixEventEvent.Status, bump); + mEvent.off(MatrixEventEvent.LocalEventIdReplaced, bump); + }; + }, [mEvent]); const { status } = mEvent; if (status === null) return null; // confirmed by server — read receipts take over let iconSrc: IconSrc; -- 2.47.3