commit 7ded784d8c850fbf98d59bd3fb5bb13b073a6c64 parent 5fc415d56ca75f6a748a4f412215ce2767739885 Author: rhunk <101876869+rhunk@users.noreply.github.com> Date: Wed, 26 Feb 2025 23:25:23 +0100 feat(core): double tap custom emoji reaction Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com> Diffstat:
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/common/src/main/assets/lang/en_US.json b/common/src/main/assets/lang/en_US.json @@ -746,6 +746,10 @@ "double_tap_chat_action": { "name": "Double Tap Chat Action", "description": "Performs a custom action when double tapping a message in chat" + }, + "double_tap_chat_action_custom_emoji": { + "name": "Double Tap Chat Action Custom Emoji Reaction", + "description": "Sets a custom emoji reaction for the double tap chat action" } } }, @@ -1393,7 +1397,8 @@ "like_message": "Like Message", "copy_text": "Copy Text to Clipboard", "delete_message": "Delete Message", - "mark_as_read": "Mark as Read" + "mark_as_read": "Mark as Read", + "custom_emoji_reaction": "Custom Emoji Reaction" } } }, diff --git a/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt b/common/src/main/kotlin/me/rhunk/snapenhance/common/config/impl/MessagingTweaks.kt @@ -98,5 +98,7 @@ class MessagingTweaks : ConfigContainer() { val bypassMessageRetentionPolicy = boolean("bypass_message_retention_policy") { addNotices(FeatureNotice.UNSTABLE); requireRestart() } val bypassMessageActionRestrictions = boolean("bypass_message_action_restrictions") { requireRestart() } val removeGroupsLockedStatus = boolean("remove_groups_locked_status") { requireRestart() } - val doubleTapChatAction = unique("double_tap_chat_action", "like_message", "copy_text", "delete_message", "mark_as_read") { requireRestart() } + val doubleTapChatAction = unique("double_tap_chat_action", "like_message", "copy_text", "delete_message", "mark_as_read", "custom_emoji_reaction") { requireRestart() } + val doubleTapChatActionCustomEmoji = string("double_tap_chat_action_custom_emoji") { + inputCheck = { it.length == 2 && it.toByteArray(Charsets.UTF_8).size >= 4 } } } \ No newline at end of file diff --git a/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/tweaks/DoubleTapChatAction.kt b/core/src/main/kotlin/me/rhunk/snapenhance/core/features/impl/tweaks/DoubleTapChatAction.kt @@ -50,6 +50,16 @@ class DoubleTapChatAction: Feature("Double Tap Chat Action") { onResult = {} ) } + + if (action == "custom_emoji_reaction") { + context.feature(Messaging::class).conversationManager?.reactToMessage( + conversationId, + messageId, + emoji = context.config.messaging.doubleTapChatActionCustomEmoji.getNullable()?.takeIf { it.isNotEmpty() } ?: "\uD83D\uDC4D", + onError = {}, + onSuccess = {} + ) + } } } }