Skip to content

Commit

Permalink
New: Limit recent folders in Manual import to 10 and descending order
Browse files Browse the repository at this point in the history
  • Loading branch information
markus101 authored and Qstick committed Oct 14, 2020
1 parent 45a3770 commit acee291
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
Expand Up @@ -93,7 +93,7 @@ class InteractiveImportSelectFolderModalContent extends Component {
>
<TableBody>
{
recentFolders.map((recentFolder) => {
recentFolders.slice(0).reverse().map((recentFolder) => {
return (
<RecentFolderRow
key={recentFolder.folder}
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/Store/Actions/interactiveImportActions.js
Expand Up @@ -19,6 +19,8 @@ export const section = 'interactiveImport';
const albumsSection = `${section}.albums`;
const trackFilesSection = `${section}.trackFiles`;

const MAXIMUM_RECENT_FOLDERS = 10;

//
// State

Expand Down Expand Up @@ -203,12 +205,14 @@ export const reducers = createHandleActions({
const index = recentFolders.findIndex((r) => r.folder === folder);

if (index > -1) {
recentFolders.splice(index, 1, recentFolder);
} else {
recentFolders.push(recentFolder);
recentFolders.splice(index, 1);
}

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 }) {
Expand Down

0 comments on commit acee291

Please sign in to comment.