Revert "refresh data from cache"

This reverts commit 60a998be89.
This commit is contained in:
sk 2023-10-26 17:53:36 +02:00
parent 55f32671c5
commit 708142e1b8
1 changed files with 0 additions and 30 deletions

View File

@ -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<List<Status>> 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<Status> cachedList){
new GetHomeTimeline(maxID, null, cachedList.size(), null, getSession().getLocalPreferences().timelineReplyVisibility).setCallback(new Callback<>(){
@Override
public void onSuccess(List<Status> result){
Map<String, Status> 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);