Skip to content

Commit

Permalink
Apply PR suggestion: move variable out of for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RenanLukas committed Mar 7, 2024
1 parent ec60f36 commit 14115d7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ class ReaderDiscoverLogic @Inject constructor(
private fun createSimplifiedJson(cardsJsonArray: JSONArray, discoverTasks: DiscoverTasks): JSONArray {
val simplifiedJsonList = mutableListOf<JSONObject>()
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
Expand Down

0 comments on commit 14115d7

Please sign in to comment.