From 708142e1b80d019ad3691ffc305a8c5dee6eebeb Mon Sep 17 00:00:00 2001 From: sk Date: Thu, 26 Oct 2023 17:53:36 +0200 Subject: [PATCH] Revert "refresh data from cache" This reverts commit 60a998be8952520c8bf0f60efd0810378a8fca76. --- .../fragments/HomeTimelineFragment.java | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java index eeffe59b0..8c00be228 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeTimelineFragment.java @@ -8,14 +8,10 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import org.joinmastodon.android.E; import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.api.requests.markers.SaveMarkers; import org.joinmastodon.android.api.requests.timelines.GetHomeTimeline; import org.joinmastodon.android.api.session.AccountSessionManager; -import org.joinmastodon.android.events.StatusCountersUpdatedEvent; -import org.joinmastodon.android.events.StatusDeletedEvent; -import org.joinmastodon.android.events.StatusUpdatedEvent; import org.joinmastodon.android.model.CacheablePaginatedResponse; import org.joinmastodon.android.model.FilterContext; import org.joinmastodon.android.model.Status; @@ -27,11 +23,9 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; import me.grishka.appkit.api.Callback; @@ -64,7 +58,6 @@ public class HomeTimelineFragment extends StatusListFragment { public void onSuccess(CacheablePaginatedResponse> result){ if(getActivity()==null) return; boolean empty=result.items.isEmpty(); - if(result.isFromCache()) refreshData(result.items); maxID=result.maxID; AccountSessionManager.get(accountID).filterStatuses(result.items, getFilterContext()); onDataLoaded(result.items, !empty); @@ -74,29 +67,6 @@ public class HomeTimelineFragment extends StatusListFragment { }); } - private void refreshData(List cachedList){ - new GetHomeTimeline(maxID, null, cachedList.size(), null, getSession().getLocalPreferences().timelineReplyVisibility).setCallback(new Callback<>(){ - @Override - public void onSuccess(List result){ - Map refreshed=result.stream().collect(Collectors.toMap(Status::getID, Function.identity())); - for(Status cached : cachedList){ - if(refreshed.containsKey(cached.id)){ - Status updated=refreshed.get(cached.id); - if(updated.editedAt!=null && cached.editedAt!=null && updated.editedAt.isAfter(cached.editedAt)) - E.post(new StatusUpdatedEvent(updated)); - else - E.post(new StatusCountersUpdatedEvent(updated)); - }else{ - removeStatus(cached); - } - } - } - - @Override - public void onError(ErrorResponse ignored){} - }).exec(accountID); - } - @Override public void onViewCreated(View view, Bundle savedInstanceState){ super.onViewCreated(view, savedInstanceState);