From 4383b11947d96eaaf901403f1ff52aa6d53cad03 Mon Sep 17 00:00:00 2001 From: FineFindus Date: Tue, 16 May 2023 16:18:02 +0200 Subject: [PATCH] refactor: move bosst check to status --- .../main/java/org/joinmastodon/android/model/Status.java | 6 ++++++ .../android/ui/displayitems/FooterStatusDisplayItem.java | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java index c1e901334..9ce3a174d 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/model/Status.java +++ b/mastodon/src/main/java/org/joinmastodon/android/model/Status.java @@ -14,6 +14,7 @@ import com.google.gson.JsonParseException; import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.api.ObjectValidationException; import org.joinmastodon.android.api.RequiredField; +import org.joinmastodon.android.api.session.AccountSessionManager; import org.joinmastodon.android.events.StatusCountersUpdatedEvent; import org.joinmastodon.android.ui.text.HtmlParser; import org.parceler.Parcel; @@ -171,6 +172,11 @@ public class Status extends BaseModel implements DisplayItemsParent, Searchable{ 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) { Status s = new Status(); s.id = id; diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java index ba4db0ea2..1bbcb1713 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/FooterStatusDisplayItem.java @@ -152,8 +152,7 @@ public class FooterStatusDisplayItem extends StatusDisplayItem{ boost.setSelected(item.status.reblogged); favorite.setSelected(item.status.favourited); bookmark.setSelected(item.status.bookmarked); - boost.setEnabled(item.status.visibility==StatusPrivacy.PUBLIC || item.status.visibility==StatusPrivacy.UNLISTED || item.status.visibility==StatusPrivacy.LOCAL - || (item.status.visibility==StatusPrivacy.PRIVATE && item.status.account.id.equals(AccountSessionManager.getInstance().getAccount(item.accountID).self.id))); + boost.setEnabled(item.status.canBeBoosted(item.accountID)); }