diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx
index d0f03e0..365bdc2 100644
--- a/src/pages/Settings.tsx
+++ b/src/pages/Settings.tsx
@@ -49,7 +49,7 @@ import {
MedalIcon,
PencilIcon,
PlusIcon,
- SatelliteDish,
+ SatelliteDishIcon,
ServerIcon,
Trash2Icon,
} from 'lucide-react'
@@ -213,7 +213,7 @@ function Settings() {
key="proxy"
title={
-
+
Proxy
}
@@ -292,11 +292,7 @@ function GeneralSection() {
const [isWorkingUpdate, setIsWorkingUpdate] = useState(false)
const [update, setUpdate] = useState(null)
- const [rcloneVersion, setRcloneVersion] = useState<{ yours: string; latest: string } | null>(
- null
- )
-
- const showServe = rcloneVersion?.yours && compareVersions(rcloneVersion.yours, '1.70.0') === 1
+ const [showServe, setShowServe] = useState(false)
async function updateCallback() {
if (!update) {
@@ -397,19 +393,28 @@ function GeneralSection() {
await getCurrentWindow().emit('relaunch-app')
}
+ function updateDisabledActions({
+ name,
+ value,
+ }: { name: (typeof disabledActions)[number]; value: boolean }) {
+ if (value) {
+ setDisabledActions(disabledActions?.filter((action) => action !== name) || [])
+ } else {
+ setDisabledActions([...(disabledActions || []), name])
+ }
+ triggerTrayRebuild()
+ }
+
useEffect(() => {
// needed since the first value from the persisted store is undefined
setPasswordInput(settingsPass || '')
}, [settingsPass])
- // biome-ignore lint/correctness/useExhaustiveDependencies:
- useEffect(() => {
- triggerTrayRebuild()
- }, [disabledActions])
-
useEffect(() => {
getRcloneVersion().then((version) => {
- setRcloneVersion(version)
+ if (version?.yours && compareVersions(version.yours, '1.70.0') === 1) {
+ setShowServe(true)
+ }
})
}, [])
@@ -525,123 +530,66 @@ function GeneralSection() {
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-mount') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-mount'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-mount', value })
+ }
>
Show Mount option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-sync') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-sync'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-sync', value })
+ }
>
Show Sync option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-copy') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-copy'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-copy', value })
+ }
>
Show Copy option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-move') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-move'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-move', value })
+ }
>
Show Move option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter(
- (action) => action !== 'tray-download'
- ) || []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-download'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-download', value })
+ }
>
Show Download option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-serve') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-serve'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-serve', value })
+ }
isDisabled={!showServe}
>
Show Serve option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-purge') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-purge'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-purge', value })
+ }
>
Show Purge option
{
- if (value) {
- setDisabledActions(
- disabledActions?.filter((action) => action !== 'tray-delete') ||
- []
- )
- } else {
- setDisabledActions([...(disabledActions || []), 'tray-delete'])
- }
- }}
+ onValueChange={(value) =>
+ updateDisabledActions({ name: 'tray-delete', value })
+ }
>
Show Delete option