New: Limit recent folders in Manual import to 10 and descending order

This commit is contained in:
Mark McDowall 2020-01-07 17:36:57 -08:00 committed by Qstick
parent 45a3770983
commit acee2915aa
2 changed files with 9 additions and 5 deletions

View file

@ -93,7 +93,7 @@ class InteractiveImportSelectFolderModalContent extends Component {
> >
<TableBody> <TableBody>
{ {
recentFolders.map((recentFolder) => { recentFolders.slice(0).reverse().map((recentFolder) => {
return ( return (
<RecentFolderRow <RecentFolderRow
key={recentFolder.folder} key={recentFolder.folder}

View file

@ -19,6 +19,8 @@ export const section = 'interactiveImport';
const albumsSection = `${section}.albums`; const albumsSection = `${section}.albums`;
const trackFilesSection = `${section}.trackFiles`; const trackFilesSection = `${section}.trackFiles`;
const MAXIMUM_RECENT_FOLDERS = 10;
// //
// State // State
@ -203,12 +205,14 @@ export const reducers = createHandleActions({
const index = recentFolders.findIndex((r) => r.folder === folder); const index = recentFolders.findIndex((r) => r.folder === folder);
if (index > -1) { if (index > -1) {
recentFolders.splice(index, 1, recentFolder); recentFolders.splice(index, 1);
} else {
recentFolders.push(recentFolder);
} }
return Object.assign({}, state, { recentFolders }); recentFolders.push(recentFolder);
const sliceIndex = Math.max(recentFolders.length - MAXIMUM_RECENT_FOLDERS, 0);
return Object.assign({}, state, { recentFolders: recentFolders.slice(sliceIndex) });
}, },
[REMOVE_RECENT_FOLDER]: function(state, { payload }) { [REMOVE_RECENT_FOLDER]: function(state, { payload }) {