refactor: move bosst check to status

This commit is contained in:
FineFindus 2023-05-16 16:18:02 +02:00
parent 22209efc37
commit 4383b11947
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
2 changed files with 7 additions and 2 deletions

View File

@ -14,6 +14,7 @@ import com.google.gson.JsonParseException;
import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.GlobalUserPreferences;
import org.joinmastodon.android.api.ObjectValidationException; import org.joinmastodon.android.api.ObjectValidationException;
import org.joinmastodon.android.api.RequiredField; import org.joinmastodon.android.api.RequiredField;
import org.joinmastodon.android.api.session.AccountSessionManager;
import org.joinmastodon.android.events.StatusCountersUpdatedEvent; import org.joinmastodon.android.events.StatusCountersUpdatedEvent;
import org.joinmastodon.android.ui.text.HtmlParser; import org.joinmastodon.android.ui.text.HtmlParser;
import org.parceler.Parcel; import org.parceler.Parcel;
@ -171,6 +172,11 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{
return strippedText; return strippedText;
} }
public boolean canBeBoosted(String accountID){
return (visibility==StatusPrivacy.PUBLIC || visibility==StatusPrivacy.UNLISTED || visibility==StatusPrivacy.LOCAL
|| (visibility==StatusPrivacy.PRIVATE && account.id.equals(AccountSessionManager.getInstance().getAccount(accountID).self.id)));
}
public static Status ofFake(String id, String text, Instant createdAt) { public static Status ofFake(String id, String text, Instant createdAt) {
Status s = new Status(); Status s = new Status();
s.id = id; s.id = id;

View File

@ -152,8 +152,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{
boost.setSelected(item.status.reblogged); boost.setSelected(item.status.reblogged);
favorite.setSelected(item.status.favourited); favorite.setSelected(item.status.favourited);
bookmark.setSelected(item.status.bookmarked); bookmark.setSelected(item.status.bookmarked);
boost.setEnabled(item.status.visibility==StatusPrivacy.PUBLIC || item.status.visibility==StatusPrivacy.UNLISTED || item.status.visibility==StatusPrivacy.LOCAL boost.setEnabled(item.status.canBeBoosted(item.accountID));
|| (item.status.visibility==StatusPrivacy.PRIVATE && item.status.account.id.equals(AccountSessionManager.getInstance().getAccount(item.accountID).self.id)));
} }