From 3b3529c69fbf2eab46bf9d8c70c4dccde6214c91 Mon Sep 17 00:00:00 2001 From: Artur Lozovski Date: Sat, 16 Dec 2023 19:25:27 +0000 Subject: [PATCH] checking multi-select --- .../webui/src/components/TorrentsList.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/crates/librqbit/webui/src/components/TorrentsList.tsx b/crates/librqbit/webui/src/components/TorrentsList.tsx index 600c5819..2f604fc1 100644 --- a/crates/librqbit/webui/src/components/TorrentsList.tsx +++ b/crates/librqbit/webui/src/components/TorrentsList.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { TorrentId } from "../api-types"; import { Spinner } from "./Spinner"; import { Torrent } from "./Torrent"; @@ -6,6 +7,14 @@ export const TorrentsList = (props: { torrents: Array | null; loading: boolean; }) => { + const [selectedRows, setSelectedRows] = useState([]); + const handleTorrentClick = (torrent: TorrentId) => { + if (selectedRows.includes(torrent)) { + setSelectedRows((prev) => prev.filter((t) => t !== torrent)); + } else { + setSelectedRows((prev) => [...prev, torrent]); + } + }; return (
{props.torrents === null ? ( @@ -16,9 +25,12 @@ export const TorrentsList = (props: {

No existing torrents found.

) : ( props.torrents.map((t: TorrentId) => ( - <> +
handleTorrentClick(t)} + > - +
)) )}