From 6a468158095f83b6e3c0bca1170069d3756449f6 Mon Sep 17 00:00:00 2001 From: Jacocococo Date: Mon, 19 Aug 2024 21:11:57 +0200 Subject: [PATCH] Prevent more reactions if max has been reached This is specifically for tapping existing reactions on a post if the user has already reached the instance max --- .../EmojiReactionsStatusDisplayItem.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java index b776ddbb7..0f819f48e 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java +++ b/mastodon/src/main/java/org/joinmastodon/android/ui/displayitems/EmojiReactionsStatusDisplayItem.java @@ -165,7 +165,7 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { private final ProgressBar progress; private final EmojiReactionsAdapter adapter; private final ListImageLoaderWrapper imgLoader; - private int meReactionCount = 0; + private int meReactionCount=0; private Instance instance; public Holder(Activity activity, ViewGroup parent) { @@ -519,9 +519,16 @@ public class EmojiReactionsStatusDisplayItem extends StatusDisplayItem { btn.setClickable(true); } btn.setOnClickListener(e->{ + EmojiReactionsAdapter adapter = (EmojiReactionsAdapter) getBindingAdapter(); + Instance instance = adapter.parentHolder.instance; + if(instance.configuration!=null && instance.configuration.reactions!=null && instance.configuration.reactions.maxReactions!=0 && + adapter.parentHolder.meReactionCount >= instance.configuration.reactions.maxReactions && + !reaction.me){ + return; + } + boolean deleting=reaction.me; parent.createRequest(reaction.name, reaction.count, deleting, this, (status)->{ - EmojiReactionsAdapter adapter = (EmojiReactionsAdapter) getBindingAdapter(); for(int i=0; i