From ab136ef6d0e59aabd77f0603f06ac18dd405b88e Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Tue, 2 Dec 2025 13:59:14 +0100 Subject: [PATCH] Display a message when the conversation is empty --- .../src/widgets/messages/RoomMessagesList.tsx | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/matrixgw_frontend/src/widgets/messages/RoomMessagesList.tsx b/matrixgw_frontend/src/widgets/messages/RoomMessagesList.tsx index 80274de..f0c0aff 100644 --- a/matrixgw_frontend/src/widgets/messages/RoomMessagesList.tsx +++ b/matrixgw_frontend/src/widgets/messages/RoomMessagesList.tsx @@ -40,16 +40,34 @@ export function RoomMessagesList(p: { users: UsersMap; manager: RoomEventsManager; }): React.ReactElement { + const listContainerRef = React.createRef(); const messagesEndRef = React.createRef(); // Automatically scroll to bottom when number of messages change React.useEffect(() => { if (messagesEndRef) messagesEndRef.current?.scrollIntoView({ behavior: "instant" }); - }, [p.manager.messages.length]); + }, [p.manager.messages.at(-1)?.event_id]); + + // Watch scroll to detect when user reach the top to load older messages + const handleScroll = () => { + if (!listContainerRef.current) return; + + const { scrollTop } = listContainerRef.current; + + if (scrollTop !== 0) { + return; + } + + console.log("reached top"); + // TODO : load old messages + // TODO : block when user reached begining of conversation + }; return (
+ {/* Empty conversation notice */} + {p.manager.messages.length === 0 && ( +
+ No message in this conversation yet! +
+ )} + {p.manager.messages.map((m, idx) => (