From 17fc14de97d384faebb39e0af531a16c582ab92b Mon Sep 17 00:00:00 2001 From: LucasGGamerM Date: Tue, 19 Sep 2023 14:26:46 -0300 Subject: [PATCH] refactor(mute-conversations-toggle): implement event for StatusMuteChanged --- .../events/StatusMuteChangedEvent.java | 15 ++++++++++ .../android/fragments/StatusListFragment.java | 25 +++++++++++++++- .../android/fragments/ThreadFragment.java | 29 ++++++++++++++++++- .../joinmastodon/android/model/Status.java | 7 +++-- .../android/ui/utils/UiUtils.java | 5 ++-- 5 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 mastodon/src/main/java/org/joinmastodon/android/events/StatusMuteChangedEvent.java diff --git a/mastodon/src/main/java/org/joinmastodon/android/events/StatusMuteChangedEvent.java b/mastodon/src/main/java/org/joinmastodon/android/events/StatusMuteChangedEvent.java new file mode 100644 index 0000000000..a0a1908e2f --- /dev/null +++ b/mastodon/src/main/java/org/joinmastodon/android/events/StatusMuteChangedEvent.java @@ -0,0 +1,15 @@ +package org.joinmastodon.android.events; + +import org.joinmastodon.android.model.Status; + +public class StatusMuteChangedEvent{ + public String id; + public boolean muted; + public Status status; + + public StatusMuteChangedEvent(Status s){ + id=s.id; + muted=s.muted; + status=s; + } +} diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java index f6b390451a..1340f649fb 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/StatusListFragment.java @@ -11,8 +11,8 @@ import org.joinmastodon.android.GlobalUserPreferences; import org.joinmastodon.android.api.session.AccountLocalPreferences; import org.joinmastodon.android.api.session.AccountSessionManager; +import org.joinmastodon.android.events.StatusMuteChangedEvent; import org.joinmastodon.android.events.EmojiReactionsUpdatedEvent; -import org.joinmastodon.android.MainActivity; import org.joinmastodon.android.events.PollUpdatedEvent; import org.joinmastodon.android.events.RemoveAccountPostsEvent; import org.joinmastodon.android.events.StatusCountersUpdatedEvent; @@ -24,6 +24,7 @@ import org.joinmastodon.android.ui.displayitems.EmojiReactionsStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.ExtendedFooterStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.FooterStatusDisplayItem; +import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem; import org.joinmastodon.android.ui.displayitems.StatusDisplayItem; import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem; import org.joinmastodon.android.ui.utils.UiUtils; @@ -257,6 +258,28 @@ public void onStatusCountersUpdated(StatusCountersUpdatedEvent ev){ } } + @Subscribe + public void onStatusMuteChaged(StatusMuteChangedEvent ev){ + for(Status s:data){ + if(s.getContentStatus().id.equals(ev.id)){ + s.getContentStatus().update(ev); + AccountSessionManager.get(accountID).getCacheController().updateStatus(s); + for(int i=0;i statuses = getDirectDescendants(ev.id, data); + for(Status s:statuses){ + s.getContentStatus().update(ev); + AccountSessionManager.get(accountID).getCacheController().updateStatus(s); + for(int i=0;i