feat(locations): remember last Add-window directory

Remember manually selected Add-window folders during the current session, with a persisted Locations toggle and cross-platform path handling.\n\nRefs #23
This commit is contained in:
NimBold
2026-07-18 11:52:24 +03:30
parent c914eeb7b3
commit 160e6af945
9 changed files with 173 additions and 9 deletions
+20
View File
@@ -48,6 +48,26 @@ interface LegacyDownloadLocationSettings {
downloadDirectories?: unknown;
}
export interface AddWindowLocationSuggestion {
path: string;
isManual: boolean;
}
export const resolveInitialAddWindowLocation = (
baseDownloadFolder: string,
rememberLastUsedDownloadDirectory: boolean,
lastUsedDownloadDirectory: string | null
): AddWindowLocationSuggestion => {
const rememberedPath = rememberLastUsedDownloadDirectory
? lastUsedDownloadDirectory?.trim()
: undefined;
const basePath = baseDownloadFolder.trim() || '~/Downloads';
return {
path: rememberedPath || basePath,
isManual: Boolean(rememberedPath)
};
};
const stringRecord = (value: unknown): Record<string, string> => {
if (!value || typeof value !== 'object') return {};
return Object.fromEntries(