From 081fe64bff989c678c95697c0e2f44cb81734501 Mon Sep 17 00:00:00 2001 From: ta264 Date: Mon, 28 Sep 2020 06:26:23 +0100 Subject: [PATCH] Revert "Convert some instances (filter, find, pick) to native from lodash" This reverts commit d8a0aac9c396acdfd4ab2342889cbf6799466c6e. --- .../Details/HistoryDetailsConnector.js | 9 +++---- .../Import/ImportMovieConnector.js | 3 ++- .../Import/ImportMovieRowConnector.js | 5 ++-- .../ImportMovie/Import/ImportMovieTable.js | 5 ++-- .../ImportMovieSelectMovieConnector.js | 3 ++- .../src/Calendar/Day/CalendarDayConnector.js | 2 +- .../Header/CalendarHeaderConnector.js | 24 +++++++++++-------- frontend/src/Components/ImportListList.js | 3 ++- .../Table/Cells/RelativeDateCellConnector.js | 13 +++++----- frontend/src/Components/TagList.js | 3 ++- frontend/src/Movie/Details/MovieDetails.js | 3 ++- .../Details/MovieReleaseDatesConnector.js | 13 +++++----- .../src/Movie/Details/MovieTagsConnector.js | 2 +- .../Edit/EditMovieModalContentConnector.js | 15 ++++++------ .../src/Movie/MovieFileStatusConnector.js | 18 ++++++++------ .../AddDownloadClientModalContentConnector.js | 5 ++-- ...ditImportExclusionModalContentConnector.js | 3 ++- .../EditRestrictionModalContentConnector.js | 3 ++- .../EditMetadataModalContentConnector.js | 3 ++- .../src/Store/Actions/movieFileActions.js | 4 ++-- frontend/src/Utilities/String/parseUrl.js | 24 ++++++++++--------- 21 files changed, 94 insertions(+), 69 deletions(-) diff --git a/frontend/src/Activity/History/Details/HistoryDetailsConnector.js b/frontend/src/Activity/History/Details/HistoryDetailsConnector.js index 65d95e557..0848c7905 100644 --- a/frontend/src/Activity/History/Details/HistoryDetailsConnector.js +++ b/frontend/src/Activity/History/Details/HistoryDetailsConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; @@ -7,10 +8,10 @@ function createMapStateToProps() { return createSelector( createUISettingsSelector(), (uiSettings) => { - return { - shortDateFormat: uiSettings.shortDateFormat, - timeFormat: uiSettings.timeFormat - }; + return _.pick(uiSettings, [ + 'shortDateFormat', + 'timeFormat' + ]); } ); } diff --git a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieConnector.js b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieConnector.js index 702e1631e..f6f92aea4 100644 --- a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieConnector.js +++ b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -41,7 +42,7 @@ function createMapStateToProps() { }; if (items.length) { - const rootFolder = items.find({ id: rootFolderId }); + const rootFolder = _.find(items, { id: rootFolderId }); return { ...result, diff --git a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieRowConnector.js b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieRowConnector.js index d7a00e9c6..b134b8ffd 100644 --- a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieRowConnector.js +++ b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieRowConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -11,7 +12,7 @@ function createImportMovieItemSelector() { (state, { id }) => id, (state) => state.importMovie.items, (id, items) => { - return items.find({ id }) || {}; + return _.find(items, { id }) || {}; } ); } @@ -22,7 +23,7 @@ function createMapStateToProps() { createAllMoviesSelector(), (item, movies) => { const selectedMovie = item && item.selectedMovie; - const isExistingMovie = !!selectedMovie && movies.some({ tmdbId: selectedMovie.tmdbId }); + const isExistingMovie = !!selectedMovie && _.some(movies, { tmdbId: selectedMovie.tmdbId }); return { ...item, diff --git a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieTable.js b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieTable.js index ad3fa1c81..89665fb0a 100644 --- a/frontend/src/AddMovie/ImportMovie/Import/ImportMovieTable.js +++ b/frontend/src/AddMovie/ImportMovie/Import/ImportMovieTable.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import VirtualTable from 'Components/Table/VirtualTable'; @@ -55,7 +56,7 @@ class ImportMovieTable extends Component { id } = prevItem; - const item = items.find({ id }); + const item = _.find(items, { id }); if (!item) { onRemoveSelectedStateItem(id); @@ -66,7 +67,7 @@ class ImportMovieTable extends Component { const isSelected = selectedState[id]; const isExistingMovie = !!selectedMovie && - prevProps.allMovies.some({ tmdbId: selectedMovie.tmdbId }); + _.some(prevProps.allMovies, { tmdbId: selectedMovie.tmdbId }); // Props doesn't have a selected movie or // the selected movie is an existing movie. diff --git a/frontend/src/AddMovie/ImportMovie/Import/SelectMovie/ImportMovieSelectMovieConnector.js b/frontend/src/AddMovie/ImportMovie/Import/SelectMovie/ImportMovieSelectMovieConnector.js index 29e43456c..31c94f294 100644 --- a/frontend/src/AddMovie/ImportMovie/Import/SelectMovie/ImportMovieSelectMovieConnector.js +++ b/frontend/src/AddMovie/ImportMovie/Import/SelectMovie/ImportMovieSelectMovieConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -45,7 +46,7 @@ class ImportMovieSelectMovieConnector extends Component { this.props.setImportMovieValue({ id, - selectedMovie: items.find({ tmdbId }) + selectedMovie: _.find(items, { tmdbId }) }); } diff --git a/frontend/src/Calendar/Day/CalendarDayConnector.js b/frontend/src/Calendar/Day/CalendarDayConnector.js index 9cff6c184..33fa1baa4 100644 --- a/frontend/src/Calendar/Day/CalendarDayConnector.js +++ b/frontend/src/Calendar/Day/CalendarDayConnector.js @@ -21,7 +21,7 @@ function createCalendarEventsConnector() { (state, { date }) => date, (state) => state.calendar.items, (date, items) => { - const filtered = items.filter((item) => { + const filtered = _.filter(items, (item) => { return (item.inCinemas && moment(date).isSame(moment(item.inCinemas), 'day')) || (item.physicalRelease && moment(date).isSame(moment(item.physicalRelease), 'day')) || (item.digitalRelease && moment(date).isSame(moment(item.digitalRelease), 'day')); diff --git a/frontend/src/Calendar/Header/CalendarHeaderConnector.js b/frontend/src/Calendar/Header/CalendarHeaderConnector.js index ba3941eab..aec2d8e55 100644 --- a/frontend/src/Calendar/Header/CalendarHeaderConnector.js +++ b/frontend/src/Calendar/Header/CalendarHeaderConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -13,16 +14,19 @@ function createMapStateToProps() { createDimensionsSelector(), createUISettingsSelector(), (calendar, dimensions, uiSettings) => { - return { - isFetching: calendar.isFetching, - view: calendar.view, - time: calendar.time, - start: calendar.start, - end: calendar.end, - isSmallScreen: dimensions.isSmallScreen, - collapseViewButtons: dimensions.isLargeScreen, - longDateFormat: uiSettings.longDateFormat - }; + const result = _.pick(calendar, [ + 'isFetching', + 'view', + 'time', + 'start', + 'end' + ]); + + result.isSmallScreen = dimensions.isSmallScreen; + result.collapseViewButtons = dimensions.isLargeScreen; + result.longDateFormat = uiSettings.longDateFormat; + + return result; } ); } diff --git a/frontend/src/Components/ImportListList.js b/frontend/src/Components/ImportListList.js index 7949bc70a..7695b26d3 100644 --- a/frontend/src/Components/ImportListList.js +++ b/frontend/src/Components/ImportListList.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; import { kinds, sizes } from 'Helpers/Props'; @@ -9,7 +10,7 @@ function ImportListList({ lists, importListList }) {
{ lists.map((t) => { - const list = importListList.find({ id: t }); + const list = _.find(importListList, { id: t }); if (!list) { return null; diff --git a/frontend/src/Components/Table/Cells/RelativeDateCellConnector.js b/frontend/src/Components/Table/Cells/RelativeDateCellConnector.js index 38783e7a5..ed996abbe 100644 --- a/frontend/src/Components/Table/Cells/RelativeDateCellConnector.js +++ b/frontend/src/Components/Table/Cells/RelativeDateCellConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; @@ -7,12 +8,12 @@ function createMapStateToProps() { return createSelector( createUISettingsSelector(), (uiSettings) => { - return { - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - longDateFormat: uiSettings.longDateFormat, - timeFormat: uiSettings.timeFormat - }; + return _.pick(uiSettings, [ + 'showRelativeDates', + 'shortDateFormat', + 'longDateFormat', + 'timeFormat' + ]); } ); } diff --git a/frontend/src/Components/TagList.js b/frontend/src/Components/TagList.js index 4d1602583..485651bdc 100644 --- a/frontend/src/Components/TagList.js +++ b/frontend/src/Components/TagList.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React from 'react'; import { kinds } from 'Helpers/Props'; @@ -9,7 +10,7 @@ function TagList({ tags, tagList }) {
{ tags.map((t) => { - const tag = tagList.find({ id: t }); + const tag = _.find(tagList, { id: t }); if (!tag) { return null; diff --git a/frontend/src/Movie/Details/MovieDetails.js b/frontend/src/Movie/Details/MovieDetails.js index e76d43d53..c505a25c1 100644 --- a/frontend/src/Movie/Details/MovieDetails.js +++ b/frontend/src/Movie/Details/MovieDetails.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { Tab, TabList, TabPanel, Tabs } from 'react-tabs'; @@ -49,7 +50,7 @@ const defaultFontSize = parseInt(fonts.defaultFontSize); const lineHeight = parseFloat(fonts.lineHeight); function getFanartUrl(images) { - const fanartImage = images.find({ coverType: 'fanart' }); + const fanartImage = _.find(images, { coverType: 'fanart' }); if (fanartImage) { // Remove protocol return fanartImage.url.replace(/^https?:/, ''); diff --git a/frontend/src/Movie/Details/MovieReleaseDatesConnector.js b/frontend/src/Movie/Details/MovieReleaseDatesConnector.js index 9c60c374b..efd6b29f7 100644 --- a/frontend/src/Movie/Details/MovieReleaseDatesConnector.js +++ b/frontend/src/Movie/Details/MovieReleaseDatesConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; @@ -7,12 +8,12 @@ function createMapStateToProps() { return createSelector( createUISettingsSelector(), (uiSettings) => { - return { - showRelativeDates: uiSettings.showRelativeDates, - shortDateFormat: uiSettings.shortDateFormat, - longDateFormat: uiSettings.longDateFormat, - timeFormat: uiSettings.timeFormat - }; + return _.pick(uiSettings, [ + 'showRelativeDates', + 'shortDateFormat', + 'longDateFormat', + 'timeFormat' + ]); } ); } diff --git a/frontend/src/Movie/Details/MovieTagsConnector.js b/frontend/src/Movie/Details/MovieTagsConnector.js index 29ed5bb02..ce03ff2c2 100644 --- a/frontend/src/Movie/Details/MovieTagsConnector.js +++ b/frontend/src/Movie/Details/MovieTagsConnector.js @@ -11,7 +11,7 @@ function createMapStateToProps() { createTagsSelector(), (movie, tagList) => { const tags = _.reduce(movie.tags, (acc, tag) => { - const matchingTag = tagList.find({ id: tag }); + const matchingTag = _.find(tagList, { id: tag }); if (matchingTag) { acc.push(matchingTag.label); diff --git a/frontend/src/Movie/Edit/EditMovieModalContentConnector.js b/frontend/src/Movie/Edit/EditMovieModalContentConnector.js index 49f5aa11e..298f934ad 100644 --- a/frontend/src/Movie/Edit/EditMovieModalContentConnector.js +++ b/frontend/src/Movie/Edit/EditMovieModalContentConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -35,13 +36,13 @@ function createMapStateToProps() { pendingChanges } = moviesState; - const movieSettings = { - monitored: movie.monitored, - qualityProfileId: movie.qualityProfileId, - minimumAvailability: movie.minimumAvailability, - path: movie.path, - tags: movie.tags - }; + const movieSettings = _.pick(movie, [ + 'monitored', + 'qualityProfileId', + 'minimumAvailability', + 'path', + 'tags' + ]); const settings = selectSettings(movieSettings, pendingChanges, saveError); diff --git a/frontend/src/Movie/MovieFileStatusConnector.js b/frontend/src/Movie/MovieFileStatusConnector.js index f015f59ec..3afaf555f 100644 --- a/frontend/src/Movie/MovieFileStatusConnector.js +++ b/frontend/src/Movie/MovieFileStatusConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -9,13 +10,16 @@ function createMapStateToProps() { return createSelector( createMovieSelector(), (movie) => { - return { - inCinemas: movie.inCinemas, - isAvailable: movie.isAvailable, - monitored: movie.monitored, - grabbed: movie.grabbed, - movieFile: movie.movieFile - }; + const result = _.pick(movie, [ + 'inCinemas', + 'isAvailable', + 'monitored', + 'grabbed' + ]); + + result.movieFile = movie.movieFile; + + return result; } ); } diff --git a/frontend/src/Settings/DownloadClients/DownloadClients/AddDownloadClientModalContentConnector.js b/frontend/src/Settings/DownloadClients/DownloadClients/AddDownloadClientModalContentConnector.js index d06b1305d..99d5c4f19 100644 --- a/frontend/src/Settings/DownloadClients/DownloadClients/AddDownloadClientModalContentConnector.js +++ b/frontend/src/Settings/DownloadClients/DownloadClients/AddDownloadClientModalContentConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -16,8 +17,8 @@ function createMapStateToProps() { schema } = downloadClients; - const usenetDownloadClients = schema.filter({ protocol: 'usenet' }); - const torrentDownloadClients = schema.filter({ protocol: 'torrent' }); + const usenetDownloadClients = _.filter(schema, { protocol: 'usenet' }); + const torrentDownloadClients = _.filter(schema, { protocol: 'torrent' }); return { isSchemaFetching, diff --git a/frontend/src/Settings/ImportLists/ImportExclusions/EditImportExclusionModalContentConnector.js b/frontend/src/Settings/ImportLists/ImportExclusions/EditImportExclusionModalContentConnector.js index fc88125f1..70ea1d873 100644 --- a/frontend/src/Settings/ImportLists/ImportExclusions/EditImportExclusionModalContentConnector.js +++ b/frontend/src/Settings/ImportLists/ImportExclusions/EditImportExclusionModalContentConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -26,7 +27,7 @@ function createImportExclusionSelector() { items } = importExclusions; - const mapping = id ? items.find({ id }) : newImportExclusion; + const mapping = id ? _.find(items, { id }) : newImportExclusion; const settings = selectSettings(mapping, pendingChanges, saveError); return { diff --git a/frontend/src/Settings/Indexers/Restrictions/EditRestrictionModalContentConnector.js b/frontend/src/Settings/Indexers/Restrictions/EditRestrictionModalContentConnector.js index 48f8fa1c0..5737826e6 100644 --- a/frontend/src/Settings/Indexers/Restrictions/EditRestrictionModalContentConnector.js +++ b/frontend/src/Settings/Indexers/Restrictions/EditRestrictionModalContentConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -26,7 +27,7 @@ function createMapStateToProps() { items } = restrictions; - const profile = id ? items.find({ id }) : newRestriction; + const profile = id ? _.find(items, { id }) : newRestriction; const settings = selectSettings(profile, pendingChanges, saveError); return { diff --git a/frontend/src/Settings/Metadata/Metadata/EditMetadataModalContentConnector.js b/frontend/src/Settings/Metadata/Metadata/EditMetadataModalContentConnector.js index 6a6027be8..6ebeb7907 100644 --- a/frontend/src/Settings/Metadata/Metadata/EditMetadataModalContentConnector.js +++ b/frontend/src/Settings/Metadata/Metadata/EditMetadataModalContentConnector.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; @@ -19,7 +20,7 @@ function createMapStateToProps() { items } = metadata; - const settings = selectSettings(items.find({ id }), pendingChanges, saveError); + const settings = selectSettings(_.find(items, { id }), pendingChanges, saveError); return { advancedSettings, diff --git a/frontend/src/Store/Actions/movieFileActions.js b/frontend/src/Store/Actions/movieFileActions.js index fe5b7a517..2a7203f57 100644 --- a/frontend/src/Store/Actions/movieFileActions.js +++ b/frontend/src/Store/Actions/movieFileActions.js @@ -68,7 +68,7 @@ export const actionHandlers = handleThunks({ deletePromise.done(() => { const movies = getState().movies.items; - const moviesWithRemovedFiles = movies.filter({ movieFileId }); + const moviesWithRemovedFiles = _.filter(movies, { movieFileId }); dispatch(batchActions([ ...moviesWithRemovedFiles.map((movie) => { @@ -100,7 +100,7 @@ export const actionHandlers = handleThunks({ promise.done(() => { const movies = getState().movies.items; const moviesWithRemovedFiles = movieFileIds.reduce((acc, movieFileId) => { - acc.push(...movies.filter({ movieFileId })); + acc.push(..._.filter(movies, { movieFileId })); return acc; }, []); diff --git a/frontend/src/Utilities/String/parseUrl.js b/frontend/src/Utilities/String/parseUrl.js index e9408e9a0..93341f85f 100644 --- a/frontend/src/Utilities/String/parseUrl.js +++ b/frontend/src/Utilities/String/parseUrl.js @@ -1,3 +1,4 @@ +import _ from 'lodash'; import qs from 'qs'; // 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 // Opera Presto. We synthesize `origin` if it's not present. While `password` // and `username` are ignored intentionally. - const properties = { - hash: anchor.hash, - host: anchor.host, - hostname: anchor.hostname, - href: anchor.href, - origin: anchor.origin, - pathname: anchor.pathname, - port: anchor.port, - protocol: anchor.protocol, - search: anchor.search - }; + const properties = _.pick( + anchor, + 'hash', + 'host', + 'hostname', + 'href', + 'origin', + 'pathname', + 'port', + 'protocol', + 'search' + ); properties.isAbsolute = (/^[\w:]*\/\//).test(url);