From d6d740a0d2a38767f525ea2c840f9549458ab88d Mon Sep 17 00:00:00 2001 From: Qstick Date: Sun, 20 Sep 2020 19:47:23 -0400 Subject: [PATCH] Replace for loop with find for QueueStatus --- .../src/Movie/Index/MovieIndexItemConnector.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/frontend/src/Movie/Index/MovieIndexItemConnector.js b/frontend/src/Movie/Index/MovieIndexItemConnector.js index 5a0ac4714..04ef32757 100644 --- a/frontend/src/Movie/Index/MovieIndexItemConnector.js +++ b/frontend/src/Movie/Index/MovieIndexItemConnector.js @@ -63,17 +63,8 @@ function createMapStateToProps() { command.body.movieIds.includes(movie.id) ); }); - - let queueStatus = null; - let queueState = null; - - for (const q in queueItems) { - if (queueItems[q].movieId === movie.id) { - queueStatus = queueItems[q].status; - queueState = queueItems[q].trackedDownloadState; - break; - } - } + + const firstQueueItem = queueItems.find((q) => q.movieId === movie.id); return { ...movie, @@ -81,8 +72,8 @@ function createMapStateToProps() { showSearchAction, isRefreshingMovie, isSearchingMovie, - queueStatus, - queueState + queueStatus: firstQueueItem.status, + queueState: firstQueueItem.trackedDownloadState }; } );