From 14115d7dfe70e5d06ecd50eae0dfe47c02d0365c Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Thu, 7 Mar 2024 15:50:10 -0300 Subject: [PATCH] Apply PR suggestion: move variable out of for loop --- .../android/ui/reader/services/discover/ReaderDiscoverLogic.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt index 1f65ac7dcc50..8e384e3626a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/reader/services/discover/ReaderDiscoverLogic.kt @@ -208,13 +208,13 @@ class ReaderDiscoverLogic @Inject constructor( private fun createSimplifiedJson(cardsJsonArray: JSONArray, discoverTasks: DiscoverTasks): JSONArray { val simplifiedJsonList = mutableListOf() var firstRecommendationCard: JSONObject? = null + val isFirstPage = discoverTasks == REQUEST_FIRST_PAGE for (i in 0 until cardsJsonArray.length()) { val cardJson = cardsJsonArray.getJSONObject(i) // We should not have a recommended blogs or interests/tags card as the first element on Discover feed. val cardType = cardJson.optString(JSON_CARD_TYPE, "") val isCardTypeRecommendation = cardType == JSON_CARD_RECOMMENDED_BLOGS || cardType == JSON_CARD_INTERESTS_YOU_MAY_LIKE - val isFirstPage = discoverTasks == REQUEST_FIRST_PAGE if (i == 0 && isFirstPage && isCardTypeRecommendation) { firstRecommendationCard = cardJson continue