This commit is contained in:
@@ -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" }}>
|
||||||
|
|||||||
Reference in New Issue
Block a user