From 71dfd0cf9a6d8a08de1d12e1e1b3d03964076525 Mon Sep 17 00:00:00 2001 From: alihamuh Date: Fri, 24 Feb 2023 12:26:43 +0500 Subject: [PATCH] web: changed config to db for trashClean up interval --- apps/web/src/views/settings.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js index 2425bcc4f..654eaf29f 100644 --- a/apps/web/src/views/settings.js +++ b/apps/web/src/views/settings.js @@ -188,9 +188,8 @@ function Settings() { "backupReminderOffset", 0 ); - const [trashLifetime, setTrashLifetime] = usePersistentState( - "trashLifetime", - 0 + const [trashCleanupInterval, setTrashCleanupInterval] = useState( + cleanupIntervalToOptions[db.settings.getTrashCleanupInterval()] ); const [debugMode, setDebugMode] = usePersistentState("debugMode", false); const [homepage, setHomepage] = usePersistentState("homepage", 0); @@ -797,10 +796,13 @@ function Settings() { title="Clear trash interval" tip={"Permanently delete all items in the trash"} options={["Weekly", "Monthly", "Yearly", "Never"]} - selectedOption={trashLifetime} - onSelectionChanged={async (_option, index) => - setTrashLifetime(index) - } + selectedOption={trashCleanupInterval} + onSelectionChanged={async (_option, index) => { + setTrashCleanupInterval(index); + db.settings.setTrashCleanupInterval( + optionsToCleanupInterval[index] + ); + }} /> )}
); } + +const optionsToCleanupInterval = { + 0: 7, + 1: 30, + 2: 365, + 3: -1 +}; + +const cleanupIntervalToOptions = { + 7: 0, + 30: 1, + 365: 2, + "-1": 3 +};