From 124b35e6a3f5373f2887e5932bf34bd01fe00003 Mon Sep 17 00:00:00 2001 From: Renan Lukas <14964993+RenanLukas@users.noreply.github.com> Date: Thu, 11 Jan 2024 19:20:19 -0300 Subject: [PATCH] Remove first tag recommendation card from Discover feed --- .../ui/reader/services/discover/ReaderDiscoverLogic.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 b8f609c866ca..17a833495dcf 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 @@ -139,7 +139,7 @@ class ReaderDiscoverLogic @Inject constructor( insertBlogsIntoDb(cards.filterIsInstance().map { it.blogs }.flatten()) // Simplify the json. The simplified version is used in the upper layers to load the data from the db. - val simplifiedCardsJson = createSimplifiedJson(fullCardsJson) + val simplifiedCardsJson = createSimplifiedJson(fullCardsJson, taskType) insertCardsJsonIntoDb(simplifiedCardsJson) val nextPageHandle = parseDiscoverCardsJsonUseCase.parseNextPageHandle(json) @@ -198,7 +198,7 @@ class ReaderDiscoverLogic @Inject constructor( * as it's already stored in the db. */ @Suppress("NestedBlockDepth") - private fun createSimplifiedJson(cardsJsonArray: JSONArray): JSONArray { + private fun createSimplifiedJson(cardsJsonArray: JSONArray, discoverTasks: DiscoverTasks): JSONArray { var index = 0 val simplifiedJson = JSONArray() for (i in 0 until cardsJsonArray.length()) { @@ -212,6 +212,10 @@ class ReaderDiscoverLogic @Inject constructor( } } JSON_CARD_INTERESTS_YOU_MAY_LIKE -> { + // We should not have an interests/tags card as the first element on Discover feed. + if (i == 0 && discoverTasks == REQUEST_FIRST_PAGE) { + continue + } simplifiedJson.put(index++, cardJson) } JSON_CARD_POST -> {