From 181a0577c81c53d5440b6776ad790e03865ad413 Mon Sep 17 00:00:00 2001 From: sk Date: Fri, 13 Oct 2023 00:24:32 +0200 Subject: [PATCH] fix missing gap item when status removed --- .../android/api/session/AccountSession.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java index 225e6bc4c..14ce14612 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/session/AccountSession.java @@ -270,6 +270,7 @@ public class AccountSession{ if(s!=null && s.filtered!=null){ localPreferences.serverSideFiltersSupported=true; localPreferences.save(); + break; } } @@ -279,9 +280,17 @@ public class AccountSession{ if(filterStatusContainingObject(o, extractor, context, profile)){ Status s=extractor.apply(o); removeUs.add(o); - if(s!=null && s.hasGapAfter && i > 0){ - Status prev=extractor.apply(objects.get(i - 1)); - if(prev!=null) prev.hasGapAfter=true; + if(s!=null && s.hasGapAfter && i>0){ + // oops, we're about to remove an item that has a gap after... + // gotta find the previous status that's not also about to be removed + for(int j=i-1; j>=0; j--){ + T p=objects.get(j); + Status prev=extractor.apply(objects.get(j)); + if(prev!=null && !removeUs.contains(p)){ + prev.hasGapAfter=true; + break; + } + } } } }