From f7623a0a44b880154035924ed09dedf69403720c Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 20 Feb 2020 05:03:28 +0300 Subject: [PATCH] Hide muted users' statuses in timelines on client side, because we're getting full timeline now(to support muted conversations) --- .../tusky/adapter/NotificationsAdapter.java | 10 ++++++++++ .../java/com/keylesspalace/tusky/entity/Status.kt | 2 +- .../tusky/fragment/TimelineFragment.java | 11 +++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java index 20a1f10d..cc92302b 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java @@ -153,6 +153,14 @@ public class NotificationsAdapter extends RecyclerView.Adapter { public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position, @NonNull List payloads) { bindViewHolder(viewHolder, position, payloads); } + + private void fixupHiddenUsers(StatusViewData.Concrete status, View v) { + if(status.isUserMuted()) { + v.setVisibility(View.GONE); + } else { + v.setVisibility(View.VISIBLE); + } + } private void bindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position, @Nullable List payloads) { Object payloadForHolder = payloads != null && !payloads.isEmpty() ? payloads.get(0) : null; @@ -179,6 +187,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { } else { holder.hideStatusInfo(); } + fixupHiddenUsers(status, holder.itemView); break; } case VIEW_TYPE_MUTED_STATUS: { @@ -186,6 +195,7 @@ public class NotificationsAdapter extends RecyclerView.Adapter { StatusViewData.Concrete status = concreteNotificaton.getStatusViewData(); holder.setupWithStatus(status, statusListener, statusDisplayOptions, payloadForHolder); + fixupHiddenUsers(status, holder.itemView); break; } case VIEW_TYPE_STATUS_NOTIFICATION: { diff --git a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt index 5a91a117..a20b05e2 100644 --- a/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt +++ b/app/src/main/java/com/keylesspalace/tusky/entity/Status.kt @@ -127,7 +127,7 @@ data class Status( } fun isUserMuted(): Boolean { - return muted && !isThreadMuted() + return muted } fun isThreadMuted(): Boolean { diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index efea31ef..3be7f899 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -153,6 +153,7 @@ public class TimelineFragment extends SFragment implements private EndlessOnScrollListener scrollListener; private boolean filterRemoveReplies; private boolean filterRemoveReblogs; + private boolean filterRemoveMutedUsers; private boolean hideFab; private boolean bottomLoading; @@ -349,6 +350,11 @@ public class TimelineFragment extends SFragment implements filter = preferences.getBoolean("tabFilterHomeBoosts", true); filterRemoveReblogs = kind == Kind.HOME && !filter; + + filterRemoveMutedUsers = kind != Kind.USER && + kind != Kind.USER_PINNED && + kind != Kind.USER_WITH_REPLIES && + kind != Kind.BOOKMARKS; reloadFilters(false); } @@ -1160,8 +1166,9 @@ public class TimelineFragment extends SFragment implements while (it.hasNext()) { Status status = it.next().asRightOrNull(); if (status != null - && ((status.getInReplyToId() != null && filterRemoveReplies) - || (status.getReblog() != null && filterRemoveReblogs) + && ((filterRemoveReplies && status.getInReplyToId() != null) + || (filterRemoveReblogs && status.getReblog() != null) + || (filterRemoveMutedUsers && status.isUserMuted()) || shouldFilterStatus(status))) { it.remove(); }