2 Commits

Author SHA1 Message Date
ac2a361b77 Can filter rooms list
All checks were successful
continuous-integration/drone/push Build is passing
2025-12-04 08:53:11 +01:00
24f8d67020 Fix bug in screen 2025-12-04 08:36:48 +01:00
3 changed files with 26 additions and 4 deletions

View File

@@ -74,7 +74,7 @@ export class MatrixApiEvent {
await APIClient.exec({ await APIClient.exec({
method: "GET", method: "GET",
uri: uri:
`/matrix/room/${encodeURIComponent(room.id)}/events?limit=400` + `/matrix/room/${encodeURIComponent(room.id)}/events?limit=200` +
(from ? `&from=${from}` : ""), (from ? `&from=${from}` : ""),
}) })
).data as MatrixEventsList; ).data as MatrixEventsList;

View File

@@ -41,7 +41,8 @@ export function MatrixAuthCallback(): React.ReactElement {
}; };
load(); load();
}, [code, info, navigate, snackbar, state]); // eslint-disable-next-line react-hooks/exhaustive-deps
}, [code, state]);
if (error) if (error)
return ( return (

View File

@@ -1,3 +1,4 @@
import SearchIcon from "@mui/icons-material/Search";
import { import {
Chip, Chip,
List, List,
@@ -5,6 +6,7 @@ import {
ListItemButton, ListItemButton,
ListItemIcon, ListItemIcon,
ListItemText, ListItemText,
TextField,
} from "@mui/material"; } from "@mui/material";
import React from "react"; import React from "react";
import type { UsersMap } from "../../api/matrix/MatrixApiProfile"; import type { UsersMap } from "../../api/matrix/MatrixApiProfile";
@@ -22,11 +24,17 @@ export function RoomSelector(p: {
}): React.ReactElement { }): React.ReactElement {
const user = useUserInfo(); const user = useUserInfo();
const [filter, setFilter] = React.useState("");
const [unread, setUnread] = React.useState(false); const [unread, setUnread] = React.useState(false);
const shownRooms = React.useMemo( const shownRooms = React.useMemo(
() => p.rooms.filter((r) => !unread || r.number_unread_messages > 0), () =>
[p.rooms, unread] p.rooms
.filter((r) => !unread || r.number_unread_messages > 0)
.filter((r) =>
r.name?.toLocaleLowerCase()?.includes(filter.toLocaleLowerCase())
),
[p.rooms, unread, filter]
); );
if (p.rooms.length === 0) if (p.rooms.length === 0)
@@ -45,6 +53,19 @@ export function RoomSelector(p: {
return ( return (
<div style={{ display: "flex", flexDirection: "column" }}> <div style={{ display: "flex", flexDirection: "column" }}>
{/** Filter bar */}
<TextField
placeholder="Filter rooms"
slotProps={{
input: {
startAdornment: <SearchIcon style={{ marginRight: "10px" }} />,
},
}}
style={{ margin: "5px" }}
value={filter}
onChange={(e) => setFilter(e.target.value)}
/>
{/** Chip bar */} {/** Chip bar */}
<div style={{ padding: "5px 10px", marginTop: "5px" }}> <div style={{ padding: "5px 10px", marginTop: "5px" }}>
<span onClick={() => setUnread(!unread)} style={{ cursor: "pointer" }}> <span onClick={() => setUnread(!unread)} style={{ cursor: "pointer" }}>