From e13630d2a758bfdadba7de91d5a3ceffb126d17f Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 6 Aug 2020 16:48:58 +0530 Subject: [PATCH 1/2] Fixed promoted stories --- .../oppia/app/home/HomeFragmentPresenter.kt | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt b/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt index 512e0fbabbd..f15886ff556 100644 --- a/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt @@ -27,6 +27,7 @@ import org.oppia.app.model.TopicList import org.oppia.app.model.TopicSummary import org.oppia.domain.oppialogger.OppiaLogger import org.oppia.domain.profile.ProfileManagementController +import org.oppia.domain.topic.StoryProgressTestHelper import org.oppia.domain.topic.TopicListController import org.oppia.util.data.AsyncResult import org.oppia.util.datetime.DateTimeUtil @@ -41,6 +42,7 @@ class HomeFragmentPresenter @Inject constructor( private val fragment: Fragment, private val profileManagementController: ProfileManagementController, private val topicListController: TopicListController, + private val storyProgressTestHelper: StoryProgressTestHelper, private val oppiaClock: OppiaClock, private val logger: ConsoleLogger, private val oppiaLogger: OppiaLogger @@ -66,6 +68,9 @@ class HomeFragmentPresenter @Inject constructor( profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() logHomeActivityEvent() + storyProgressTestHelper.markPartialStoryProgressForFractions(profileId, true) + storyProgressTestHelper.markTwoPartialStoryProgressForRatios(profileId, true) + welcomeViewModel = WelcomeViewModel() promotedStoryListViewModel = PromotedStoryListViewModel(activity, internalProfileId) allTopicsViewModel = AllTopicsViewModel() @@ -180,10 +185,20 @@ class HomeFragmentPresenter @Inject constructor( getAssumedSuccessfulOngoingStoryList().observe( fragment, Observer { - it.recentStoryList.take(limit).forEach { promotedStory -> - val recentStory = PromotedStoryViewModel(activity, internalProfileId) - recentStory.setPromotedStory(promotedStory) - promotedStoryList.add(recentStory) + promotedStoryList.clear() + if (it.recentStoryCount != 0) { + it.recentStoryList.take(limit).forEach { promotedStory -> + val recentStory = PromotedStoryViewModel(activity, internalProfileId) + recentStory.setPromotedStory(promotedStory) + promotedStoryList.add(recentStory) + } + } else { + // TODO(#936): Optimise this as part of recommended stories. + it.olderStoryList.take(limit).forEach { promotedStory -> + val oldStory = PromotedStoryViewModel(activity, internalProfileId) + oldStory.setPromotedStory(promotedStory) + promotedStoryList.add(oldStory) + } } topicListAdapter.notifyItemChanged(1) } From 999c86e49ae9bb485abb16b5064b297fe438aa99 Mon Sep 17 00:00:00 2001 From: Rajat Talesra Date: Thu, 6 Aug 2020 16:49:37 +0530 Subject: [PATCH 2/2] Nit revert --- .../main/java/org/oppia/app/home/HomeFragmentPresenter.kt | 5 ----- 1 file changed, 5 deletions(-) diff --git a/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt b/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt index f15886ff556..1cc4876facf 100644 --- a/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt +++ b/app/src/main/java/org/oppia/app/home/HomeFragmentPresenter.kt @@ -27,7 +27,6 @@ import org.oppia.app.model.TopicList import org.oppia.app.model.TopicSummary import org.oppia.domain.oppialogger.OppiaLogger import org.oppia.domain.profile.ProfileManagementController -import org.oppia.domain.topic.StoryProgressTestHelper import org.oppia.domain.topic.TopicListController import org.oppia.util.data.AsyncResult import org.oppia.util.datetime.DateTimeUtil @@ -42,7 +41,6 @@ class HomeFragmentPresenter @Inject constructor( private val fragment: Fragment, private val profileManagementController: ProfileManagementController, private val topicListController: TopicListController, - private val storyProgressTestHelper: StoryProgressTestHelper, private val oppiaClock: OppiaClock, private val logger: ConsoleLogger, private val oppiaLogger: OppiaLogger @@ -68,9 +66,6 @@ class HomeFragmentPresenter @Inject constructor( profileId = ProfileId.newBuilder().setInternalId(internalProfileId).build() logHomeActivityEvent() - storyProgressTestHelper.markPartialStoryProgressForFractions(profileId, true) - storyProgressTestHelper.markTwoPartialStoryProgressForRatios(profileId, true) - welcomeViewModel = WelcomeViewModel() promotedStoryListViewModel = PromotedStoryListViewModel(activity, internalProfileId) allTopicsViewModel = AllTopicsViewModel()