mirror of
https://github.com/Sonarr/Sonarr.git
synced 2026-04-20 21:54:58 -04:00
37 lines
756 B
TypeScript
37 lines
756 B
TypeScript
import { createSelector } from 'reselect';
|
|
import AppState from 'App/State/AppState';
|
|
|
|
function createPathsSelector() {
|
|
return createSelector(
|
|
(state: AppState) => state.paths,
|
|
(paths) => {
|
|
const {
|
|
isFetching,
|
|
isPopulated,
|
|
error,
|
|
parent,
|
|
currentPath,
|
|
directories,
|
|
files,
|
|
} = paths;
|
|
|
|
const filteredPaths = [...directories, ...files].filter(({ path }) => {
|
|
return path.toLowerCase().startsWith(currentPath.toLowerCase());
|
|
});
|
|
|
|
return {
|
|
isFetching,
|
|
isPopulated,
|
|
error,
|
|
parent,
|
|
currentPath,
|
|
directories,
|
|
files,
|
|
paths: filteredPaths,
|
|
};
|
|
}
|
|
);
|
|
}
|
|
|
|
export default createPathsSelector;
|