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
@@ -14,6 +14,7 @@ import {
formatDerivedCategoryPath,
normalizeCategorySubfolder,
normalizeDownloadLocationSettings,
resolveInitialAddWindowLocation,
resolveCategoryDestination,
subfolderFromDerivedCategoryPath
} from './downloadLocations';
@@ -24,6 +25,25 @@ describe('download locations', () => {
expect(downloadLocationEquals('/Users/Test', 'Movie.MP4', '/users/test', 'movie.mp4', 'macos')).toBe(false);
expect(downloadLocationEquals('/home/Test', 'Movie.MP4', '/home/test', 'movie.mp4', 'linux')).toBe(false);
});
it('uses a remembered Add-window directory only when the setting is enabled', () => {
expect(resolveInitialAddWindowLocation(
'D:\\Downloads',
true,
'D:\\Course_Videos'
)).toEqual({ path: 'D:\\Course_Videos', isManual: true });
expect(resolveInitialAddWindowLocation(
'D:\\Downloads',
false,
'D:\\Course_Videos'
)).toEqual({ path: 'D:\\Downloads', isManual: false });
});
it('falls back to the normalized base folder when no directory was remembered', () => {
expect(resolveInitialAddWindowLocation(' ', true, null))
.toEqual({ path: '~/Downloads', isManual: false });
});
beforeEach(() => {
vi.clearAllMocks();
});