diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index a4a3643d..371fb2c2 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -24,6 +24,9 @@ crate-type = ["staticlib", "cdylib", "lib"] [profile.release] strip = true # Automatically strip symbols from the binary. +[features] +cargo-clippy = [] + [build-dependencies] tauri-build = { version = "2.0.4", features = [] } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c84ac111..7bb13bab 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1764,7 +1764,7 @@ pub fn run() { .level(if is_dev() { log::LevelFilter::Debug } else { log::LevelFilter::Info }) .build(), ) - .plugin(tauri_plugin_single_instance::init(|app, args, _cwd| { + .plugin(tauri_plugin_single_instance::init(|app, _args, _cwd| { // When trying to open a new app instance (common operation on Linux), // focus the first existing window we find instead of opening a new one // TODO: Keep track of the last focused window and always focus that one diff --git a/src-web/components/CreateWorkspaceDialog.tsx b/src-web/components/CreateWorkspaceDialog.tsx index 97d789bd..b3560369 100644 --- a/src-web/components/CreateWorkspaceDialog.tsx +++ b/src-web/components/CreateWorkspaceDialog.tsx @@ -6,7 +6,6 @@ import { getWorkspaceMeta } from '../lib/store'; import { Button } from './core/Button'; import { PlainInput } from './core/PlainInput'; import { VStack } from './core/Stacks'; -import type { SyncToFilesystemSettingProps } from './SyncToFilesystemSetting'; import { SyncToFilesystemSetting } from './SyncToFilesystemSetting'; interface Props { @@ -15,9 +14,7 @@ interface Props { export function CreateWorkspaceDialog({ hide }: Props) { const [name, setName] = useState(''); - const [settingSyncDir, setSettingSyncDir] = useState< - Parameters[0] - >({ value: null, enabled: false }); + const [settingSyncDir, setSettingSyncDir] = useState(null); return ( { e.preventDefault(); - const { enabled, value } = settingSyncDir ?? {}; - if (enabled && !value) return; + if (!settingSyncDir) return; const workspace = await upsertWorkspace.mutateAsync({ name }); if (workspace == null) return; // Do getWorkspaceMeta instead of naively creating one because it might have // been created already when the store refreshes the workspace meta after const workspaceMeta = await getWorkspaceMeta(workspace.id); - upsertWorkspaceMeta.mutate({ ...workspaceMeta, settingSyncDir: value }); + upsertWorkspaceMeta.mutate({ ...workspaceMeta, settingSyncDir }); // Navigate to workspace await router.navigate({ @@ -46,19 +42,14 @@ export function CreateWorkspaceDialog({ hide }: Props) { hide(); }} > - + - diff --git a/src-web/components/SyncToFilesystemSetting.tsx b/src-web/components/SyncToFilesystemSetting.tsx index 129b7e72..eb588ebd 100644 --- a/src-web/components/SyncToFilesystemSetting.tsx +++ b/src-web/components/SyncToFilesystemSetting.tsx @@ -1,11 +1,11 @@ import { readDir } from '@tauri-apps/plugin-fs'; import { useState } from 'react'; -import { Checkbox } from './core/Checkbox'; +import { Banner } from './core/Banner'; import { VStack } from './core/Stacks'; import { SelectFile } from './SelectFile'; export interface SyncToFilesystemSettingProps { - onChange: (args: { value: string | null; enabled: boolean }) => void; + onChange: (filePath: string | null) => void; value: string | null; allowNonEmptyDirectory?: boolean; } @@ -15,47 +15,37 @@ export function SyncToFilesystemSetting({ value, allowNonEmptyDirectory, }: SyncToFilesystemSettingProps) { - const [useSyncDir, setUseSyncDir] = useState(!!value); const [error, setError] = useState(null); return ( - - { - setUseSyncDir(enabled); - if (!enabled) { - // Set value to null when disabling - onChange({ value: null, enabled }); - } else { - onChange({ value, enabled }); - } - }} - title="Sync to a filesystem directory" - /> - {error &&
{error}
} - {useSyncDir && ( +
+ Sync to filesystem + + + When enabled, workspace data syncs to the chosen folder as text files, ideal for backup + and Git collaboration. + + {error &&
{error}
} + { - setError(null); - if (filePath == null) { - setUseSyncDir(false); - } else { + if (filePath != null) { const files = await readDir(filePath); if (files.length > 0 && !allowNonEmptyDirectory) { - setError('Directory must be empty'); + setError('The directory must be empty'); return; } } - onChange({ value: filePath, enabled: useSyncDir }); + onChange(filePath); }} /> - )} -
+ +
); } diff --git a/src-web/components/WorkspaceSettingsDialog.tsx b/src-web/components/WorkspaceSettingsDialog.tsx index 4b83f437..2187aaf2 100644 --- a/src-web/components/WorkspaceSettingsDialog.tsx +++ b/src-web/components/WorkspaceSettingsDialog.tsx @@ -41,7 +41,7 @@ export function WorkspaceSettingsDialog({ workspaceId, hide }: Props) { return ( upsertWorkspace.mutate({ ...workspace, name })} stateKey={`name.${workspace.id}`} @@ -60,9 +60,9 @@ export function WorkspaceSettingsDialog({ workspaceId, hide }: Props) { { - upsertWorkspaceMeta.mutate({ ...workspaceMeta, settingSyncDir }); - }} + onChange={(settingSyncDir) => + upsertWorkspaceMeta.mutate({ ...workspaceMeta, settingSyncDir }) + } />