From 1a5a021711bce8083961ad8da75c142b030737a4 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 3 Dec 2025 08:53:44 +0100 Subject: [PATCH] Can filter to show only unread rooms --- .../src/widgets/messages/RoomSelector.tsx | 103 +++++++++++------- 1 file changed, 64 insertions(+), 39 deletions(-) diff --git a/matrixgw_frontend/src/widgets/messages/RoomSelector.tsx b/matrixgw_frontend/src/widgets/messages/RoomSelector.tsx index c908696..258402e 100644 --- a/matrixgw_frontend/src/widgets/messages/RoomSelector.tsx +++ b/matrixgw_frontend/src/widgets/messages/RoomSelector.tsx @@ -6,6 +6,7 @@ import { ListItemIcon, ListItemText, } from "@mui/material"; +import React from "react"; import type { UsersMap } from "../../api/matrix/MatrixApiProfile"; import { roomName, type Room } from "../../api/matrix/MatrixApiRoom"; import { useUserInfo } from "../dashboard/BaseAuthenticatedPage"; @@ -21,6 +22,13 @@ export function RoomSelector(p: { }): React.ReactElement { const user = useUserInfo(); + const [unread, setUnread] = React.useState(false); + + const shownRooms = React.useMemo( + () => p.rooms.filter((r) => !unread || r.number_unread_messages > 0), + [p.rooms, unread] + ); + if (p.rooms.length === 0) return (
- {p.rooms.map((r) => ( - - ) - } - disablePadding - > - p.onChange(r)} - dense - selected={p.currRoom?.id === r.id} +
+ {/** Chip bar */} +
+ setUnread(!unread)} style={{ cursor: "pointer" }}> + + +
+ + {/** Rooms list */} + + {shownRooms.map((r) => ( + + ) + } + disablePadding > - - - - 0 ? "bold" : undefined, - }} - > - {roomName(user.info, r, p.users)} - - } - /> - - - ))} - + p.onChange(r)} + dense + selected={p.currRoom?.id === r.id} + > + + + + 0 ? "bold" : undefined, + }} + > + {roomName(user.info, r, p.users)} + + } + /> + + + ))} + +
); }