Merge branch 'main' into fork

This commit is contained in:
sk 2022-11-21 14:10:49 +01:00
commit 8918bd5ce2
6 changed files with 18 additions and 7 deletions

View File

@ -73,7 +73,7 @@ public class CacheController{
status.hasGapAfter=((flags & POST_FLAG_GAP_AFTER)!=0);
newMaxID=status.id;
for(Filter filter:filters){
if(filter.matches(status.getContentStatus().content))
if(filter.matches(status))
continue outer;
}
result.add(status);
@ -146,7 +146,7 @@ public class CacheController{
newMaxID=ntf.id;
if(ntf.status!=null){
for(Filter filter:filters){
if(filter.matches(ntf.status.getContentStatus().content))
if(filter.matches(ntf.status))
continue outer;
}
}
@ -167,7 +167,7 @@ public class CacheController{
callback.onSuccess(new PaginatedResponse<>(result.stream().filter(ntf->{
if(ntf.status!=null){
for(Filter filter:filters){
if(filter.matches(ntf.status.getContentStatus().content)){
if(filter.matches(ntf.status)){
return false;
}
}

View File

@ -268,7 +268,7 @@ public class HomeTimelineFragment extends StatusListFragment{
if(idsBelowGap.contains(s.id))
break;
for(Filter filter:filters){
if(filter.matches(s.getContentStatus().content)){
if(filter.matches(s)){
continue outer;
}
}

View File

@ -97,7 +97,7 @@ public class ThreadFragment extends StatusListFragment{
return statuses;
return statuses.stream().filter(status->{
for(Filter filter:filters){
if(filter.matches(status.getContentStatus().content))
if(filter.matches(status))
return false;
}
return true;

View File

@ -50,6 +50,10 @@ public class Filter extends BaseModel{
return pattern.matcher(text).find();
}
public boolean matches(Status status){
return matches(status.getContentStatus().getStrippedText());
}
@Override
public String toString(){
return "Filter{"+

View File

@ -4,6 +4,7 @@ import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField;
import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
import org.joinmastodon.android.ui.text.HtmlParser;
import org.parceler.Parcel;
import java.time.Instant;
@ -57,6 +58,7 @@ public class Status extends BaseModel implements DisplayItemsParent{
public transient boolean spoilerRevealed;
public transient boolean hasGapAfter;
private transient String strippedText;
@Override
public void postprocess() throws ObjectValidationException{
@ -134,4 +136,10 @@ public class Status extends BaseModel implements DisplayItemsParent{
public Status getContentStatus(){
return reblog!=null ? reblog : this;
}
public String getStrippedText(){
if(strippedText==null)
strippedText=HtmlParser.strip(content);
return strippedText;
}
}

View File

@ -21,9 +21,8 @@ public class StatusFilterPredicate implements Predicate<Status>{
@Override
public boolean test(Status status){
CharSequence content=status.getContentStatus().content;
for(Filter filter:filters){
if(filter.matches(content))
if(filter.matches(status))
return false;
}
return true;