diff --git a/starsky/starsky/clientapp/src/components/molecules/menu-option-move-to-trash/menu-option-move-to-trash.tsx b/starsky/starsky/clientapp/src/components/molecules/menu-option-move-to-trash/menu-option-move-to-trash.tsx index a0561da16a..b2770c1776 100644 --- a/starsky/starsky/clientapp/src/components/molecules/menu-option-move-to-trash/menu-option-move-to-trash.tsx +++ b/starsky/starsky/clientapp/src/components/molecules/menu-option-move-to-trash/menu-option-move-to-trash.tsx @@ -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[]; @@ -26,14 +25,9 @@ interface IMenuOptionMoveToTrashProps { */ const MenuOptionMoveToTrash: React.FunctionComponent = 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() { @@ -53,17 +47,15 @@ const MenuOptionMoveToTrash: React.FunctionComponent { - moveToTrashSelection(); - }); + useHotKeys({ key: "Delete" }, moveToTrashSelection); return ( <> {select.length >= 1 ? ( -
  • { - event.key === "Enter" && moveToTrashSelection(); + { + await moveToTrashSelection(); }} - onClick={() => moveToTrashSelection()} - > - {MessageMoveToTrash} -
  • + localization={localization.MessageMoveToTrash} + /> ) : null} );