Files
lanspread/crates/lanspread-tauri-deno-ts/src/components/topbar/DirectoryButton.tsx
T
ddidderr 31ace174e3 fix(ui): treat missing game folders as unset
Validate the persisted game directory before sending it to the backend or
showing library content for it. When the saved path no longer exists, the
launcher keeps the top bar visible but shows the folder picker empty state
and labels the Game Folder button as an unset folder.

This keeps stale local data from being presented as the active library when
an old path is deleted or disconnected.

Test Plan:
- git diff --check
- just frontend-test
- just build
2026-05-21 21:32:28 +02:00

30 lines
914 B
TypeScript

import { Icon } from '../Icon';
interface Props {
path: string | null;
exists: boolean;
onClick: () => void;
}
export const DirectoryButton = ({ path, exists, onClick }: Props) => {
const isSet = !!(path && path.trim());
const isValid = isSet && exists;
const label = isValid ? 'Game folder' : 'Set game folder';
const tooltip = isValid ? (path as string) : 'Please select a game folder';
const ariaLabel = isValid ? `Game folder: ${path}` : 'Set game folder';
return (
<button
type="button"
className={`dirbtn ${isValid ? 'dirbtn-set' : 'dirbtn-unset'}`}
title={tooltip}
aria-label={ariaLabel}
onClick={onClick}
>
<Icon.folder />
<span className="dirbtn-label">{label}</span>
<span className="dirbtn-status-dot" aria-hidden="true" />
</button>
);
};