open item by default if url query has item id
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { ItemDetails } from "../api/useItemsQuery";
|
||||
import { useItemTorrentsQuery } from "../api/useItemTorrentsQuery";
|
||||
import {
|
||||
@@ -39,6 +39,16 @@ export const Item = ({ item }: ItemProps) => {
|
||||
|
||||
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) => {
|
||||
downloadMutation.mutate({ torrentId });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user