From 50ba1acc2368d2874ed6a9f44ea8f5f12f451585 Mon Sep 17 00:00:00 2001 From: LavaDesu Date: Tue, 15 Jul 2025 19:19:54 +1000 Subject: [PATCH] feat(canary/ComponentsV2): 7.15.1 @ LavaDesu/Aliucord@0116d81ce24e8c4dc1d9d577bea65067405fee7f --- canary/ComponentsV2/build.gradle.kts | 5 ++++- .../main/kotlin/com/aliucord/coreplugins/ComponentsV2.kt | 7 +++++++ .../aliucord/coreplugins/componentsv2/PatchMessageItems.kt | 3 ++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/canary/ComponentsV2/build.gradle.kts b/canary/ComponentsV2/build.gradle.kts index 2f7d5dd..d4cb46a 100644 --- a/canary/ComponentsV2/build.gradle.kts +++ b/canary/ComponentsV2/build.gradle.kts @@ -1,6 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -version = "7.15.0" +version = "7.15.1" description = "Beta backport of ComponentsV2" aliucord { @@ -14,6 +14,9 @@ aliucord { Changelog {added marginTop} ====================== + # 7.15.1 + * Fix broken reply preview >w< + # 7.15.0 * Initial release >w< """.trimIndent()) diff --git a/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/ComponentsV2.kt b/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/ComponentsV2.kt index 82684e0..61acc91 100644 --- a/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/ComponentsV2.kt +++ b/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/ComponentsV2.kt @@ -19,6 +19,7 @@ import com.discord.api.botuikit.gson.ComponentRuntimeTypeAdapter import com.discord.api.botuikit.gson.ComponentTypeTypeAdapter import com.discord.api.message.attachment.MessageAttachment import com.discord.models.botuikit.* +import com.discord.models.message.Message import com.discord.stores.StoreApplicationInteractions.InteractionSendState import com.discord.utilities.view.extensions.ViewExtensions import com.discord.widgets.botuikit.* @@ -33,6 +34,8 @@ import com.lytefast.flexinput.R import de.robv.android.xposed.XposedBridge import java.io.File +val Message.isComponentV2 get() = (flags shr 15) and 1 == 1L + @AliucordPlugin(requiresRestart = true) @Suppress("unused") class ComponentsV2 : Plugin() { @@ -194,6 +197,10 @@ class ComponentsV2 : Plugin() { else -> null } } + + patcher.after("shouldShowReplyPreviewAsAttachment") { param -> + if (this.isComponentV2) param.result = true + } } override fun stop(context: Context) { diff --git a/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/componentsv2/PatchMessageItems.kt b/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/componentsv2/PatchMessageItems.kt index 6c12a46..9c13ff1 100644 --- a/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/componentsv2/PatchMessageItems.kt +++ b/canary/ComponentsV2/src/main/kotlin/com/aliucord/coreplugins/componentsv2/PatchMessageItems.kt @@ -1,6 +1,7 @@ package com.aliucord.coreplugins.componentsv2 import com.aliucord.api.PatcherAPI +import com.aliucord.coreplugins.isComponentV2 import com.aliucord.patcher.* import com.discord.api.channel.Channel import com.discord.api.role.GuildRole @@ -34,7 +35,7 @@ fun patchMessageItems(patcher: PatcherAPI) { val result = (param.result as MutableList) val meId = param.args[15] as Long result.forEachIndexed { index, entry -> - if (entry is BotUiComponentEntry && ((entry.message.flags shr 15) and 1 == 1L)) { + if (entry is BotUiComponentEntry && entry.message.isComponentV2) { val fields = BotUiComponentV2Entry.V2Fields(state, meId, channel, guildMembers, guildRoles) result[index] = BotUiComponentV2Entry.fromV1(entry, fields) }