open item by default if url query has item id

This commit is contained in:
2026-02-18 22:39:05 +03:00
parent fa47c328cc
commit d231f9a79e

View File

@@ -1,4 +1,4 @@
import { useState } from "react"; import { useEffect, useState } from "react";
import type { ItemDetails } from "../api/useItemsQuery"; import type { ItemDetails } from "../api/useItemsQuery";
import { useItemTorrentsQuery } from "../api/useItemTorrentsQuery"; import { useItemTorrentsQuery } from "../api/useItemTorrentsQuery";
import { import {
@@ -39,6 +39,16 @@ export const Item = ({ item }: ItemProps) => {
const Icon = open ? CaretUpIcon : CaretDownIcon; const Icon = open ? CaretUpIcon : CaretDownIcon;
useEffect(() => {
const params = new URLSearchParams(location.search);
const itemId = params.get("item");
if (itemId && parseInt(itemId) === item.id) {
// fuck this stupid rule
// eslint-disable-next-line
setOpen(true);
}
}, [item]);
const handleDownloadTorrent = (torrentId: number) => { const handleDownloadTorrent = (torrentId: number) => {
downloadMutation.mutate({ torrentId }); downloadMutation.mutate({ torrentId });
}; };