From 0d465d3bee6a97b425b13bdd9bea5907dbc05475 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 23 Sep 2019 17:09:13 +0200 Subject: [PATCH] remove duplicate request when timeline is empty (#1491) --- .../tusky/fragment/TimelineFragment.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index 3bf38f691..a4dc23b8e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -68,7 +68,6 @@ import com.keylesspalace.tusky.view.EndlessOnScrollListener; import com.keylesspalace.tusky.viewdata.StatusViewData; import java.io.IOException; -import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -286,12 +285,12 @@ public class TimelineFragment extends SFragment implements } private void updateCurrent() { - String topId; if (this.statuses.isEmpty()) { - topId = null; - } else { - topId = CollectionsKt.first(this.statuses, Either::isRight).asRight().getId(); + return; } + + String topId = CollectionsKt.first(this.statuses, Either::isRight).asRight().getId(); + this.timelineRepo.getStatuses(topId, null, null, LOAD_AT_ONCE, TimelineRequestMode.NETWORK) .observeOn(AndroidSchedulers.mainThread()) @@ -303,7 +302,7 @@ public class TimelineFragment extends SFragment implements if (!statuses.isEmpty()) { filterStatuses(statuses); - if (!this.statuses.isEmpty() && topId != null) { + if (!this.statuses.isEmpty()) { // clear old cached statuses Iterator> iterator = this.statuses.iterator(); while (iterator.hasNext()) {