Skip to content

Commit

Permalink
refactor(statusDisplayItem): move status hidden filter check to start…
Browse files Browse the repository at this point in the history
… of method to allow an early return

This optimises things by not computing the list of stuff when the status is simply not going to be rendered
  • Loading branch information
LucasGGamerM committed Dec 21, 2023
1 parent 18e3fad commit 4d9f625
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ public static ArrayList<StatusDisplayItem> buildItems(BaseStatusListFragment<?>
args.putString("account", accountID);
ScheduledStatus scheduledStatus = parentObject instanceof ScheduledStatus s ? s : null;

// Hide statuses that have a filter action of hide
if(!new StatusFilterPredicate(accountID, filterContext, FilterAction.HIDE).test(status))
return new ArrayList<StatusDisplayItem>() ;

HeaderStatusDisplayItem header=null;
boolean hideCounts=!AccountSessionManager.get(accountID).getLocalPreferences().showInteractionCounts;

Expand Down Expand Up @@ -363,10 +367,6 @@ public static ArrayList<StatusDisplayItem> buildItems(BaseStatusListFragment<?>
}
}

// Hide statuses that have a filter action of hide
if(!new StatusFilterPredicate(accountID, filterContext, FilterAction.HIDE).test(status))
return new ArrayList<StatusDisplayItem>() ;

List<StatusDisplayItem> nonGapItems=gap!=null ? items.subList(0, items.size()-1) : items;
WarningFilteredStatusDisplayItem warning=applyingFilter==null ? null :
new WarningFilteredStatusDisplayItem(parentID, fragment, statusForContent, nonGapItems, applyingFilter);
Expand Down

0 comments on commit 4d9f625

Please sign in to comment.