From f3e1fa4b2bc073db6d64c89c833e7103819d02a7 Mon Sep 17 00:00:00 2001 From: sk Date: Mon, 12 Jun 2023 01:01:45 +0200 Subject: [PATCH] fix announcements loading infinitely closes sk22#569 --- .../android/fragments/AnnouncementsFragment.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/AnnouncementsFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/AnnouncementsFragment.java index 1b6b8ce2a..430c1205b 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/AnnouncementsFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/AnnouncementsFragment.java @@ -94,12 +94,15 @@ public class AnnouncementsFragment extends BaseStatusListFragment @Override public void onSuccess(List result){ if (getActivity() == null) return; - List unread = result.stream().filter(a -> !a.read).collect(toList()); - List read = result.stream().filter(a -> a.read).collect(toList()); - onDataLoaded(unread, true); - onDataLoaded(read, false); - if (unread.isEmpty()) setResult(true, null); - else unreadIDs = unread.stream().map(a -> a.id).collect(toList()); + + // get unread items first + List data = result.stream().filter(a -> !a.read).collect(toList()); + if (data.isEmpty()) setResult(true, null); + else unreadIDs = data.stream().map(a -> a.id).collect(toList()); + + // append read items at the end + data.addAll(result.stream().filter(a -> a.read).collect(toList())); + onDataLoaded(data, false); } }) .exec(accountID);