Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
qdraw committed Dec 6, 2023
1 parent 3cd882b commit bdde68b
Showing 1 changed file with 13 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import React, { memo } from "react";
import { ArchiveAction } from "../../../contexts/archive-context";
import useGlobalSettings from "../../../hooks/use-global-settings";
import useHotKeys from "../../../hooks/use-keyboard/use-hotkeys";
import useLocation from "../../../hooks/use-location/use-location";
import { IArchiveProps } from "../../../interfaces/IArchiveProps";
import localization from "../../../localization/localization.json";
import FetchPost from "../../../shared/fetch-post";
import { FileListCache } from "../../../shared/filelist-cache";
import { Language } from "../../../shared/language";
import { ClearSearchCache } from "../../../shared/search/clear-search-cache";
import { Select } from "../../../shared/select";
import { URLPath } from "../../../shared/url-path";
import { UrlQuery } from "../../../shared/url-query";
import MenuOption from "../../atoms/menu-option/menu-option.tsx";

interface IMenuOptionMoveToTrashProps {
select: string[];
Expand All @@ -26,14 +25,9 @@ interface IMenuOptionMoveToTrashProps {
*/
const MenuOptionMoveToTrash: React.FunctionComponent<IMenuOptionMoveToTrashProps> =
memo(({ state, dispatch, select, setSelect, isReadOnly }) => {
const settings = useGlobalSettings();
const language = new Language(settings.language);

const undoSelection = () =>
new Select(select, setSelect, state, history).undoSelection();

const MessageMoveToTrash = language.key(localization.MessageMoveToTrash);

const history = useLocation();

async function moveToTrashSelection() {
Expand All @@ -53,17 +47,15 @@ const MenuOptionMoveToTrash: React.FunctionComponent<IMenuOptionMoveToTrashProps

const bodyParams = new URLSearchParams();
// noinspection PointlessBooleanExpressionJS
const collections = new URLPath().StringToIUrl(history.location.search).collections !==
const collections =
new URLPath().StringToIUrl(history.location.search).collections !==
false;

bodyParams.append("f", selectParams);
bodyParams.set("Tags", "!delete!");
bodyParams.set("append", "true");
bodyParams.set("Colorclass", "8");
bodyParams.set(
"collections",
collections.toString()
);
bodyParams.set("collections", collections.toString());

const resultDo = await FetchPost(
new UrlQuery().UrlMoveToTrashApi(),
Expand All @@ -89,25 +81,20 @@ const MenuOptionMoveToTrash: React.FunctionComponent<IMenuOptionMoveToTrashProps
/**
* When pressing delete its moved to the trash
*/
useHotKeys({ key: "Delete" }, () => {
moveToTrashSelection();
});
useHotKeys({ key: "Delete" }, moveToTrashSelection);

return (
<>
{select.length >= 1 ? (
<li
data-test="trash"
tabIndex={0}
role="button"
className={!isReadOnly ? "menu-option" : "menu-option disabled"}
onKeyDown={(event) => {
event.key === "Enter" && moveToTrashSelection();
<MenuOption
isReadOnly={isReadOnly}
testName={"trash"}
isSet={false}
set={async () => {
await moveToTrashSelection();
}}
onClick={() => moveToTrashSelection()}
>
{MessageMoveToTrash}
</li>
localization={localization.MessageMoveToTrash}
/>
) : null}
</>
);
Expand Down

0 comments on commit bdde68b

Please sign in to comment.