Revert "Convert some instances (filter, find, pick) to native from lodash"

This reverts commit d8a0aac9c3.
pull/5080/head
ta264 4 years ago
parent 9075fdc1c1
commit 081fe64bff

@ -1,3 +1,4 @@
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';
@ -7,10 +8,10 @@ function createMapStateToProps() {
return createSelector( return createSelector(
createUISettingsSelector(), createUISettingsSelector(),
(uiSettings) => { (uiSettings) => {
return { return _.pick(uiSettings, [
shortDateFormat: uiSettings.shortDateFormat, 'shortDateFormat',
timeFormat: uiSettings.timeFormat 'timeFormat'
}; ]);
} }
); );
} }

@ -1,3 +1,4 @@
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';
@ -41,7 +42,7 @@ function createMapStateToProps() {
}; };
if (items.length) { if (items.length) {
const rootFolder = items.find({ id: rootFolderId }); const rootFolder = _.find(items, { id: rootFolderId });
return { return {
...result, ...result,

@ -1,3 +1,4 @@
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';
@ -11,7 +12,7 @@ function createImportMovieItemSelector() {
(state, { id }) => id, (state, { id }) => id,
(state) => state.importMovie.items, (state) => state.importMovie.items,
(id, items) => { (id, items) => {
return items.find({ id }) || {}; return _.find(items, { id }) || {};
} }
); );
} }
@ -22,7 +23,7 @@ function createMapStateToProps() {
createAllMoviesSelector(), createAllMoviesSelector(),
(item, movies) => { (item, movies) => {
const selectedMovie = item && item.selectedMovie; const selectedMovie = item && item.selectedMovie;
const isExistingMovie = !!selectedMovie && movies.some({ tmdbId: selectedMovie.tmdbId }); const isExistingMovie = !!selectedMovie && _.some(movies, { tmdbId: selectedMovie.tmdbId });
return { return {
...item, ...item,

@ -1,3 +1,4 @@
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';
@ -55,7 +56,7 @@ class ImportMovieTable extends Component {
id id
} = prevItem; } = prevItem;
const item = items.find({ id }); const item = _.find(items, { id });
if (!item) { if (!item) {
onRemoveSelectedStateItem(id); onRemoveSelectedStateItem(id);
@ -66,7 +67,7 @@ class ImportMovieTable extends Component {
const isSelected = selectedState[id]; const isSelected = selectedState[id];
const isExistingMovie = !!selectedMovie && const isExistingMovie = !!selectedMovie &&
prevProps.allMovies.some({ tmdbId: selectedMovie.tmdbId }); _.some(prevProps.allMovies, { 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,3 +1,4 @@
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';
@ -45,7 +46,7 @@ class ImportMovieSelectMovieConnector extends Component {
this.props.setImportMovieValue({ this.props.setImportMovieValue({
id, id,
selectedMovie: items.find({ tmdbId }) selectedMovie: _.find(items, { 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 = items.filter((item) => { const filtered = _.filter(items, (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,3 +1,4 @@
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';
@ -13,16 +14,19 @@ function createMapStateToProps() {
createDimensionsSelector(), createDimensionsSelector(),
createUISettingsSelector(), createUISettingsSelector(),
(calendar, dimensions, uiSettings) => { (calendar, dimensions, uiSettings) => {
return { const result = _.pick(calendar, [
isFetching: calendar.isFetching, 'isFetching',
view: calendar.view, 'view',
time: calendar.time, 'time',
start: calendar.start, 'start',
end: calendar.end, 'end'
isSmallScreen: dimensions.isSmallScreen, ]);
collapseViewButtons: dimensions.isLargeScreen,
longDateFormat: uiSettings.longDateFormat result.isSmallScreen = dimensions.isSmallScreen;
}; result.collapseViewButtons = dimensions.isLargeScreen;
result.longDateFormat = uiSettings.longDateFormat;
return result;
} }
); );
} }

@ -1,3 +1,4 @@
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';
@ -9,7 +10,7 @@ function ImportListList({ lists, importListList }) {
<div className={styles.lists}> <div className={styles.lists}>
{ {
lists.map((t) => { lists.map((t) => {
const list = importListList.find({ id: t }); const list = _.find(importListList, { id: t });
if (!list) { if (!list) {
return null; return null;

@ -1,3 +1,4 @@
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';
@ -7,12 +8,12 @@ function createMapStateToProps() {
return createSelector( return createSelector(
createUISettingsSelector(), createUISettingsSelector(),
(uiSettings) => { (uiSettings) => {
return { return _.pick(uiSettings, [
showRelativeDates: uiSettings.showRelativeDates, 'showRelativeDates',
shortDateFormat: uiSettings.shortDateFormat, 'shortDateFormat',
longDateFormat: uiSettings.longDateFormat, 'longDateFormat',
timeFormat: uiSettings.timeFormat 'timeFormat'
}; ]);
} }
); );
} }

@ -1,3 +1,4 @@
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';
@ -9,7 +10,7 @@ function TagList({ tags, tagList }) {
<div className={styles.tags}> <div className={styles.tags}>
{ {
tags.map((t) => { tags.map((t) => {
const tag = tagList.find({ id: t }); const tag = _.find(tagList, { id: t });
if (!tag) { if (!tag) {
return null; return null;

@ -1,3 +1,4 @@
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';
@ -49,7 +50,7 @@ const defaultFontSize = parseInt(fonts.defaultFontSize);
const lineHeight = parseFloat(fonts.lineHeight); const lineHeight = parseFloat(fonts.lineHeight);
function getFanartUrl(images) { function getFanartUrl(images) {
const fanartImage = images.find({ coverType: 'fanart' }); const fanartImage = _.find(images, { coverType: 'fanart' });
if (fanartImage) { if (fanartImage) {
// Remove protocol // Remove protocol
return fanartImage.url.replace(/^https?:/, ''); return fanartImage.url.replace(/^https?:/, '');

@ -1,3 +1,4 @@
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';
@ -7,12 +8,12 @@ function createMapStateToProps() {
return createSelector( return createSelector(
createUISettingsSelector(), createUISettingsSelector(),
(uiSettings) => { (uiSettings) => {
return { return _.pick(uiSettings, [
showRelativeDates: uiSettings.showRelativeDates, 'showRelativeDates',
shortDateFormat: uiSettings.shortDateFormat, 'shortDateFormat',
longDateFormat: uiSettings.longDateFormat, 'longDateFormat',
timeFormat: uiSettings.timeFormat '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 = tagList.find({ id: tag }); const matchingTag = _.find(tagList, { id: tag });
if (matchingTag) { if (matchingTag) {
acc.push(matchingTag.label); acc.push(matchingTag.label);

@ -1,3 +1,4 @@
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';
@ -35,13 +36,13 @@ function createMapStateToProps() {
pendingChanges pendingChanges
} = moviesState; } = moviesState;
const movieSettings = { const movieSettings = _.pick(movie, [
monitored: movie.monitored, 'monitored',
qualityProfileId: movie.qualityProfileId, 'qualityProfileId',
minimumAvailability: movie.minimumAvailability, 'minimumAvailability',
path: movie.path, 'path',
tags: movie.tags 'tags'
}; ]);
const settings = selectSettings(movieSettings, pendingChanges, saveError); const settings = selectSettings(movieSettings, pendingChanges, saveError);

@ -1,3 +1,4 @@
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';
@ -9,13 +10,16 @@ function createMapStateToProps() {
return createSelector( return createSelector(
createMovieSelector(), createMovieSelector(),
(movie) => { (movie) => {
return { const result = _.pick(movie, [
inCinemas: movie.inCinemas, 'inCinemas',
isAvailable: movie.isAvailable, 'isAvailable',
monitored: movie.monitored, 'monitored',
grabbed: movie.grabbed, 'grabbed'
movieFile: movie.movieFile ]);
};
result.movieFile = movie.movieFile;
return result;
} }
); );
} }

@ -1,3 +1,4 @@
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';
@ -16,8 +17,8 @@ function createMapStateToProps() {
schema schema
} = downloadClients; } = downloadClients;
const usenetDownloadClients = schema.filter({ protocol: 'usenet' }); const usenetDownloadClients = _.filter(schema, { protocol: 'usenet' });
const torrentDownloadClients = schema.filter({ protocol: 'torrent' }); const torrentDownloadClients = _.filter(schema, { protocol: 'torrent' });
return { return {
isSchemaFetching, isSchemaFetching,

@ -1,3 +1,4 @@
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';
@ -26,7 +27,7 @@ function createImportExclusionSelector() {
items items
} = importExclusions; } = importExclusions;
const mapping = id ? items.find({ id }) : newImportExclusion; const mapping = id ? _.find(items, { id }) : newImportExclusion;
const settings = selectSettings(mapping, pendingChanges, saveError); const settings = selectSettings(mapping, pendingChanges, saveError);
return { return {

@ -1,3 +1,4 @@
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';
@ -26,7 +27,7 @@ function createMapStateToProps() {
items items
} = restrictions; } = restrictions;
const profile = id ? items.find({ id }) : newRestriction; const profile = id ? _.find(items, { id }) : newRestriction;
const settings = selectSettings(profile, pendingChanges, saveError); const settings = selectSettings(profile, pendingChanges, saveError);
return { return {

@ -1,3 +1,4 @@
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';
@ -19,7 +20,7 @@ function createMapStateToProps() {
items items
} = metadata; } = metadata;
const settings = selectSettings(items.find({ id }), pendingChanges, saveError); const settings = selectSettings(_.find(items, { 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 = movies.filter({ movieFileId }); const moviesWithRemovedFiles = _.filter(movies, { 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(...movies.filter({ movieFileId })); acc.push(..._.filter(movies, { movieFileId }));
return acc; return acc;
}, []); }, []);

@ -1,3 +1,4 @@
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
@ -9,17 +10,18 @@ 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 = { const properties = _.pick(
hash: anchor.hash, anchor,
host: anchor.host, 'hash',
hostname: anchor.hostname, 'host',
href: anchor.href, 'hostname',
origin: anchor.origin, 'href',
pathname: anchor.pathname, 'origin',
port: anchor.port, 'pathname',
protocol: anchor.protocol, 'port',
search: anchor.search 'protocol',
}; 'search'
);
properties.isAbsolute = (/^[\w:]*\/\//).test(url); properties.isAbsolute = (/^[\w:]*\/\//).test(url);

Loading…
Cancel
Save