mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-25 18:17:21 +00:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user