diff --git a/src/components/modals/interfacepanel.tsx b/src/components/modals/interfacepanel.tsx index 8a98201..e70056a 100644 --- a/src/components/modals/interfacepanel.tsx +++ b/src/components/modals/interfacepanel.tsx @@ -21,7 +21,7 @@ import { Checkbox, Grid, NativeSelect, NumberInput, Textarea, useMantineTheme } import type { UseFormReturnType } from "@mantine/form"; import ColorChooser from "components/colorchooser"; import { useGlobalStyleOverrides } from "themehooks"; -import type { ColorSetting, StyleOverrides } from "config"; +import { DeleteTorrentDataOptions, type ColorSetting, type DeleteTorrentDataOption, type StyleOverrides } from "config"; import { ColorSchemeToggle } from "components/miscbuttons"; const { TAURI, invoke } = await import(/* webpackChunkName: "taurishim" */"taurishim"); @@ -29,6 +29,7 @@ export interface InterfaceFormValues { interface: { styleOverrides: StyleOverrides, skipAddDialog: boolean, + deleteTorrentData: DeleteTorrentDataOption, numLastSaveDirs: number, defaultTrackers: string[], }, @@ -111,6 +112,14 @@ export function InterfaceSettigsPanel(props: { fo + + Delete torrent data + + + { setFieldValue("interface.deleteTorrentData", e.target.value); }} /> + Max number of saved download directories (false); + useEffect(() => { + if (props.opened) { + if (config.values.interface.deleteTorrentData !== "remember selection") { + setDeleteData(config.values.interface.deleteTorrentData === "default on"); + } else { + setDeleteData(config.values.interface.deleteTorrentDataSelection); + } + } + }, [config, props.opened]); + + const onDeleteDataChanged = useCallback((e: React.ChangeEvent) => { + const value = e.currentTarget.checked; + setDeleteData(value); + config.values.interface.deleteTorrentDataSelection = value; + }, [config]); + const remove = useRemoveTorrents(); const onDelete = useCallback(() => { @@ -57,7 +75,7 @@ export function RemoveModal(props: ModalState) { { setDeleteData(e.currentTarget.checked); }} + onChange={onDeleteDataChanged} my="xl" /> diff --git a/src/config.ts b/src/config.ts index 8fb93a8..4d725f2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -95,8 +95,10 @@ export type SectionsVisibility = Array<{ export const WindowMinimizeOptions = ["minimize", "hide"] as const; export const WindowCloseOptions = ["hide", "close", "quit"] as const; +export const DeleteTorrentDataOptions = ["default off", "default on", "remember selection"] as const; export type WindowMinimizeOption = typeof WindowMinimizeOptions[number]; export type WindowCloseOption = typeof WindowCloseOptions[number]; +export type DeleteTorrentDataOption = typeof DeleteTorrentDataOptions[number]; export interface ColorSetting { color: DefaultMantineColor, @@ -149,6 +151,8 @@ interface Settings { showFilesSearchBox: boolean, mainSplit: SplitType, skipAddDialog: boolean, + deleteTorrentData: DeleteTorrentDataOption, + deleteTorrentDataSelection: boolean, numLastSaveDirs: number, defaultTrackers: string[], styleOverrides: StyleOverrides, @@ -260,6 +264,8 @@ const DefaultSettings: Settings = { showFilesSearchBox: false, mainSplit: "vertical", skipAddDialog: false, + deleteTorrentData: "default off", + deleteTorrentDataSelection: false, numLastSaveDirs: 20, defaultTrackers: [...DefaultTrackerList], styleOverrides: {