From 91affcf63e76a7001b9b80755db581508efd8fc3 Mon Sep 17 00:00:00 2001 From: Kanahia Date: Tue, 16 Jul 2024 14:10:18 +0530 Subject: [PATCH] Fixed irrelevant network call --- .../ContributionBoundaryCallback.kt | 1 + .../ContributionsListFragment.java | 4 ++-- .../ContributionsListPresenter.java | 18 +++--------------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionBoundaryCallback.kt b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionBoundaryCallback.kt index b75332b73..91de03135 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionBoundaryCallback.kt +++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionBoundaryCallback.kt @@ -47,6 +47,7 @@ class ContributionBoundaryCallback @Inject constructor( * fetched from the network */ override fun onItemAtEndLoaded(itemAtEnd: Contribution) { + Timber.tag("PRINT").e("fetching2") fetchContributions() } diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java index 2dd9b7671..6c697148f 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListFragment.java @@ -214,12 +214,12 @@ public class ContributionsListFragment extends CommonsDaggerSupportFragment impl contributionsListPresenter.setup(userName, Objects.equals(sessionManager.getUserName(), userName)); - contributionsListPresenter.getPendingContributions(userName); + contributionsListPresenter.getPendingContributions(); contributionsListPresenter.pendingContributionList.observe(getViewLifecycleOwner(), list -> { pendingUploadsCount = list.size(); callback.updatePendingIcon(pendingUploadsCount); }); - contributionsListPresenter.getFailedContributions(userName); + contributionsListPresenter.getFailedContributions(); contributionsListPresenter.failedContributionList.observe(getViewLifecycleOwner(), list -> { uploadErrorCount = list.size(); callback.updateErrorIcon(uploadErrorCount); diff --git a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListPresenter.java b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListPresenter.java index 70ef95ce5..cc1d8e5bb 100644 --- a/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListPresenter.java +++ b/app/src/main/java/fr/free/nrw/commons/contributions/ContributionsListPresenter.java @@ -95,44 +95,32 @@ public class ContributionsListPresenter implements UserActionListener { contributionBoundaryCallback.dispose(); } - void getPendingContributions(String userName) { + void getPendingContributions() { final PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) .setPrefetchDistance(50) .setPageSize(10).build(); Factory factory; - boolean shouldSetBoundaryCallback; - contributionBoundaryCallback.setUserName(userName); - shouldSetBoundaryCallback = true; - factory = repository.fetchContributionsWithStates( Arrays.asList(Contribution.STATE_IN_PROGRESS, Contribution.STATE_QUEUED, Contribution.STATE_PAUSED)); LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory, pagedListConfig); - if (shouldSetBoundaryCallback) { - livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback); - } pendingContributionList = livePagedListBuilder.build(); } - void getFailedContributions(String userName) { + void getFailedContributions() { final PagedList.Config pagedListConfig = (new PagedList.Config.Builder()) .setPrefetchDistance(50) .setPageSize(10).build(); Factory factory; - boolean shouldSetBoundaryCallback; - contributionBoundaryCallback.setUserName(userName); - shouldSetBoundaryCallback = true; factory = repository.fetchContributionsWithStates( Collections.singletonList(Contribution.STATE_FAILED)); + LivePagedListBuilder livePagedListBuilder = new LivePagedListBuilder(factory, pagedListConfig); - if (shouldSetBoundaryCallback) { - livePagedListBuilder.setBoundaryCallback(contributionBoundaryCallback); - } failedContributionList = livePagedListBuilder.build(); }