mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
Convert some instances (filter, find, pick) to native from lodash
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
@@ -8,10 +7,10 @@ function createMapStateToProps() {
|
|||||||
return createSelector(
|
return createSelector(
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(uiSettings) => {
|
(uiSettings) => {
|
||||||
return _.pick(uiSettings, [
|
return {
|
||||||
'shortDateFormat',
|
shortDateFormat: uiSettings.shortDateFormat,
|
||||||
'timeFormat'
|
timeFormat: uiSettings.timeFormat
|
||||||
]);
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -42,7 +41,7 @@ function createMapStateToProps() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (items.length) {
|
if (items.length) {
|
||||||
const rootFolder = _.find(items, { id: rootFolderId });
|
const rootFolder = items.find({ id: rootFolderId });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -12,7 +11,7 @@ function createImportMovieItemSelector() {
|
|||||||
(state, { id }) => id,
|
(state, { id }) => id,
|
||||||
(state) => state.importMovie.items,
|
(state) => state.importMovie.items,
|
||||||
(id, items) => {
|
(id, items) => {
|
||||||
return _.find(items, { id }) || {};
|
return items.find({ id }) || {};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -23,7 +22,7 @@ function createMapStateToProps() {
|
|||||||
createAllMoviesSelector(),
|
createAllMoviesSelector(),
|
||||||
(item, movies) => {
|
(item, movies) => {
|
||||||
const selectedMovie = item && item.selectedMovie;
|
const selectedMovie = item && item.selectedMovie;
|
||||||
const isExistingMovie = !!selectedMovie && _.some(movies, { tmdbId: selectedMovie.tmdbId });
|
const isExistingMovie = !!selectedMovie && movies.some({ tmdbId: selectedMovie.tmdbId });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import VirtualTable from 'Components/Table/VirtualTable';
|
import VirtualTable from 'Components/Table/VirtualTable';
|
||||||
@@ -56,7 +55,7 @@ class ImportMovieTable extends Component {
|
|||||||
id
|
id
|
||||||
} = prevItem;
|
} = prevItem;
|
||||||
|
|
||||||
const item = _.find(items, { id });
|
const item = items.find({ id });
|
||||||
|
|
||||||
if (!item) {
|
if (!item) {
|
||||||
onRemoveSelectedStateItem(id);
|
onRemoveSelectedStateItem(id);
|
||||||
@@ -67,7 +66,7 @@ class ImportMovieTable extends Component {
|
|||||||
const isSelected = selectedState[id];
|
const isSelected = selectedState[id];
|
||||||
|
|
||||||
const isExistingMovie = !!selectedMovie &&
|
const isExistingMovie = !!selectedMovie &&
|
||||||
_.some(prevProps.allMovies, { tmdbId: selectedMovie.tmdbId });
|
prevProps.allMovies.some({ tmdbId: selectedMovie.tmdbId });
|
||||||
|
|
||||||
// Props doesn't have a selected movie or
|
// Props doesn't have a selected movie or
|
||||||
// the selected movie is an existing movie.
|
// the selected movie is an existing movie.
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -46,7 +45,7 @@ class ImportMovieSelectMovieConnector extends Component {
|
|||||||
|
|
||||||
this.props.setImportMovieValue({
|
this.props.setImportMovieValue({
|
||||||
id,
|
id,
|
||||||
selectedMovie: _.find(items, { tmdbId })
|
selectedMovie: items.find({ tmdbId })
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ function createCalendarEventsConnector() {
|
|||||||
(state, { date }) => date,
|
(state, { date }) => date,
|
||||||
(state) => state.calendar.items,
|
(state) => state.calendar.items,
|
||||||
(date, items) => {
|
(date, items) => {
|
||||||
const filtered = _.filter(items, (item) => {
|
const filtered = items.filter((item) => {
|
||||||
return (item.inCinemas && moment(date).isSame(moment(item.inCinemas), 'day')) ||
|
return (item.inCinemas && moment(date).isSame(moment(item.inCinemas), 'day')) ||
|
||||||
(item.physicalRelease && moment(date).isSame(moment(item.physicalRelease), 'day')) ||
|
(item.physicalRelease && moment(date).isSame(moment(item.physicalRelease), 'day')) ||
|
||||||
(item.digitalRelease && moment(date).isSame(moment(item.digitalRelease), 'day'));
|
(item.digitalRelease && moment(date).isSame(moment(item.digitalRelease), 'day'));
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -14,19 +13,16 @@ function createMapStateToProps() {
|
|||||||
createDimensionsSelector(),
|
createDimensionsSelector(),
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(calendar, dimensions, uiSettings) => {
|
(calendar, dimensions, uiSettings) => {
|
||||||
const result = _.pick(calendar, [
|
return {
|
||||||
'isFetching',
|
isFetching: calendar.isFetching,
|
||||||
'view',
|
view: calendar.view,
|
||||||
'time',
|
time: calendar.time,
|
||||||
'start',
|
start: calendar.start,
|
||||||
'end'
|
end: calendar.end,
|
||||||
]);
|
isSmallScreen: dimensions.isSmallScreen,
|
||||||
|
collapseViewButtons: dimensions.isLargeScreen,
|
||||||
result.isSmallScreen = dimensions.isSmallScreen;
|
longDateFormat: uiSettings.longDateFormat
|
||||||
result.collapseViewButtons = dimensions.isLargeScreen;
|
};
|
||||||
result.longDateFormat = uiSettings.longDateFormat;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { kinds, sizes } from 'Helpers/Props';
|
import { kinds, sizes } from 'Helpers/Props';
|
||||||
@@ -10,7 +9,7 @@ function ImportListList({ lists, importListList }) {
|
|||||||
<div className={styles.lists}>
|
<div className={styles.lists}>
|
||||||
{
|
{
|
||||||
lists.map((t) => {
|
lists.map((t) => {
|
||||||
const list = _.find(importListList, { id: t });
|
const list = importListList.find({ id: t });
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
@@ -8,12 +7,12 @@ function createMapStateToProps() {
|
|||||||
return createSelector(
|
return createSelector(
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(uiSettings) => {
|
(uiSettings) => {
|
||||||
return _.pick(uiSettings, [
|
return {
|
||||||
'showRelativeDates',
|
showRelativeDates: uiSettings.showRelativeDates,
|
||||||
'shortDateFormat',
|
shortDateFormat: uiSettings.shortDateFormat,
|
||||||
'longDateFormat',
|
longDateFormat: uiSettings.longDateFormat,
|
||||||
'timeFormat'
|
timeFormat: uiSettings.timeFormat
|
||||||
]);
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { kinds } from 'Helpers/Props';
|
import { kinds } from 'Helpers/Props';
|
||||||
@@ -10,7 +9,7 @@ function TagList({ tags, tagList }) {
|
|||||||
<div className={styles.tags}>
|
<div className={styles.tags}>
|
||||||
{
|
{
|
||||||
tags.map((t) => {
|
tags.map((t) => {
|
||||||
const tag = _.find(tagList, { id: t });
|
const tag = tagList.find({ id: t });
|
||||||
|
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
return null;
|
return null;
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Tab, TabList, TabPanel, Tabs } from 'react-tabs';
|
import { Tab, TabList, TabPanel, Tabs } from 'react-tabs';
|
||||||
@@ -50,7 +49,7 @@ const defaultFontSize = parseInt(fonts.defaultFontSize);
|
|||||||
const lineHeight = parseFloat(fonts.lineHeight);
|
const lineHeight = parseFloat(fonts.lineHeight);
|
||||||
|
|
||||||
function getFanartUrl(images) {
|
function getFanartUrl(images) {
|
||||||
const fanartImage = _.find(images, { coverType: 'fanart' });
|
const fanartImage = images.find({ coverType: 'fanart' });
|
||||||
if (fanartImage) {
|
if (fanartImage) {
|
||||||
// Remove protocol
|
// Remove protocol
|
||||||
return fanartImage.url.replace(/^https?:/, '');
|
return fanartImage.url.replace(/^https?:/, '');
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
|
||||||
@@ -8,12 +7,12 @@ function createMapStateToProps() {
|
|||||||
return createSelector(
|
return createSelector(
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(uiSettings) => {
|
(uiSettings) => {
|
||||||
return _.pick(uiSettings, [
|
return {
|
||||||
'showRelativeDates',
|
showRelativeDates: uiSettings.showRelativeDates,
|
||||||
'shortDateFormat',
|
shortDateFormat: uiSettings.shortDateFormat,
|
||||||
'longDateFormat',
|
longDateFormat: uiSettings.longDateFormat,
|
||||||
'timeFormat'
|
timeFormat: uiSettings.timeFormat
|
||||||
]);
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@ function createMapStateToProps() {
|
|||||||
createTagsSelector(),
|
createTagsSelector(),
|
||||||
(movie, tagList) => {
|
(movie, tagList) => {
|
||||||
const tags = _.reduce(movie.tags, (acc, tag) => {
|
const tags = _.reduce(movie.tags, (acc, tag) => {
|
||||||
const matchingTag = _.find(tagList, { id: tag });
|
const matchingTag = tagList.find({ id: tag });
|
||||||
|
|
||||||
if (matchingTag) {
|
if (matchingTag) {
|
||||||
acc.push(matchingTag.label);
|
acc.push(matchingTag.label);
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -36,13 +35,13 @@ function createMapStateToProps() {
|
|||||||
pendingChanges
|
pendingChanges
|
||||||
} = moviesState;
|
} = moviesState;
|
||||||
|
|
||||||
const movieSettings = _.pick(movie, [
|
const movieSettings = {
|
||||||
'monitored',
|
monitored: movie.monitored,
|
||||||
'qualityProfileId',
|
qualityProfileId: movie.qualityProfileId,
|
||||||
'minimumAvailability',
|
minimumAvailability: movie.minimumAvailability,
|
||||||
'path',
|
path: movie.path,
|
||||||
'tags'
|
tags: movie.tags
|
||||||
]);
|
};
|
||||||
|
|
||||||
const settings = selectSettings(movieSettings, pendingChanges, saveError);
|
const settings = selectSettings(movieSettings, pendingChanges, saveError);
|
||||||
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -10,16 +9,13 @@ function createMapStateToProps() {
|
|||||||
return createSelector(
|
return createSelector(
|
||||||
createMovieSelector(),
|
createMovieSelector(),
|
||||||
(movie) => {
|
(movie) => {
|
||||||
const result = _.pick(movie, [
|
return {
|
||||||
'inCinemas',
|
inCinemas: movie.inCinemas,
|
||||||
'isAvailable',
|
isAvailable: movie.isAvailable,
|
||||||
'monitored',
|
monitored: movie.monitored,
|
||||||
'grabbed'
|
grabbed: movie.grabbed,
|
||||||
]);
|
movieFile: movie.movieFile
|
||||||
|
};
|
||||||
result.movieFile = movie.movieFile;
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -17,8 +16,8 @@ function createMapStateToProps() {
|
|||||||
schema
|
schema
|
||||||
} = downloadClients;
|
} = downloadClients;
|
||||||
|
|
||||||
const usenetDownloadClients = _.filter(schema, { protocol: 'usenet' });
|
const usenetDownloadClients = schema.filter({ protocol: 'usenet' });
|
||||||
const torrentDownloadClients = _.filter(schema, { protocol: 'torrent' });
|
const torrentDownloadClients = schema.filter({ protocol: 'torrent' });
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isSchemaFetching,
|
isSchemaFetching,
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -27,7 +26,7 @@ function createImportExclusionSelector() {
|
|||||||
items
|
items
|
||||||
} = importExclusions;
|
} = importExclusions;
|
||||||
|
|
||||||
const mapping = id ? _.find(items, { id }) : newImportExclusion;
|
const mapping = id ? items.find({ id }) : newImportExclusion;
|
||||||
const settings = selectSettings(mapping, pendingChanges, saveError);
|
const settings = selectSettings(mapping, pendingChanges, saveError);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -27,7 +26,7 @@ function createMapStateToProps() {
|
|||||||
items
|
items
|
||||||
} = restrictions;
|
} = restrictions;
|
||||||
|
|
||||||
const profile = id ? _.find(items, { id }) : newRestriction;
|
const profile = id ? items.find({ id }) : newRestriction;
|
||||||
const settings = selectSettings(profile, pendingChanges, saveError);
|
const settings = selectSettings(profile, pendingChanges, saveError);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
@@ -20,7 +19,7 @@ function createMapStateToProps() {
|
|||||||
items
|
items
|
||||||
} = metadata;
|
} = metadata;
|
||||||
|
|
||||||
const settings = selectSettings(_.find(items, { id }), pendingChanges, saveError);
|
const settings = selectSettings(items.find({ id }), pendingChanges, saveError);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
advancedSettings,
|
advancedSettings,
|
||||||
|
@@ -68,7 +68,7 @@ export const actionHandlers = handleThunks({
|
|||||||
|
|
||||||
deletePromise.done(() => {
|
deletePromise.done(() => {
|
||||||
const movies = getState().movies.items;
|
const movies = getState().movies.items;
|
||||||
const moviesWithRemovedFiles = _.filter(movies, { movieFileId });
|
const moviesWithRemovedFiles = movies.filter({ movieFileId });
|
||||||
|
|
||||||
dispatch(batchActions([
|
dispatch(batchActions([
|
||||||
...moviesWithRemovedFiles.map((movie) => {
|
...moviesWithRemovedFiles.map((movie) => {
|
||||||
@@ -100,7 +100,7 @@ export const actionHandlers = handleThunks({
|
|||||||
promise.done(() => {
|
promise.done(() => {
|
||||||
const movies = getState().movies.items;
|
const movies = getState().movies.items;
|
||||||
const moviesWithRemovedFiles = movieFileIds.reduce((acc, movieFileId) => {
|
const moviesWithRemovedFiles = movieFileIds.reduce((acc, movieFileId) => {
|
||||||
acc.push(..._.filter(movies, { movieFileId }));
|
acc.push(...movies.filter({ movieFileId }));
|
||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
import _ from 'lodash';
|
|
||||||
import qs from 'qs';
|
import qs from 'qs';
|
||||||
|
|
||||||
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils
|
// See: https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils
|
||||||
@@ -10,18 +9,17 @@ export default function parseUrl(url) {
|
|||||||
// The `origin`, `password`, and `username` properties are unavailable in
|
// The `origin`, `password`, and `username` properties are unavailable in
|
||||||
// Opera Presto. We synthesize `origin` if it's not present. While `password`
|
// Opera Presto. We synthesize `origin` if it's not present. While `password`
|
||||||
// and `username` are ignored intentionally.
|
// and `username` are ignored intentionally.
|
||||||
const properties = _.pick(
|
const properties = {
|
||||||
anchor,
|
hash: anchor.hash,
|
||||||
'hash',
|
host: anchor.host,
|
||||||
'host',
|
hostname: anchor.hostname,
|
||||||
'hostname',
|
href: anchor.href,
|
||||||
'href',
|
origin: anchor.origin,
|
||||||
'origin',
|
pathname: anchor.pathname,
|
||||||
'pathname',
|
port: anchor.port,
|
||||||
'port',
|
protocol: anchor.protocol,
|
||||||
'protocol',
|
search: anchor.search
|
||||||
'search'
|
};
|
||||||
);
|
|
||||||
|
|
||||||
properties.isAbsolute = (/^[\w:]*\/\//).test(url);
|
properties.isAbsolute = (/^[\w:]*\/\//).test(url);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user