diff --git a/plugins/HideGiftButton/src/index.ts b/plugins/HideGiftButton/src/index.ts index 0b653cb..89c9d2c 100644 --- a/plugins/HideGiftButton/src/index.ts +++ b/plugins/HideGiftButton/src/index.ts @@ -1,19 +1,27 @@ -import { findByName } from "@vendetta/metro"; +import { findByName, findByProps } from "@vendetta/metro"; import { after } from "@vendetta/patcher"; import { getAssetIDByName } from "@vendetta/ui/assets"; import { findInReactTree } from "@vendetta/utils"; -const ChatInput = findByName("ChatInput"); +const ChatInputGift = findByProps("ChatInput"); +const ChatInputThreads = findByName("ChatInput"); -let unpatch: () => boolean; +let unpatchGift: () => boolean; +let unpatchThreads: () => boolean; export default { onLoad() { const blockList = ["ic_thread_normal_24px", "ic_gift"].map(n => getAssetIDByName(n)); - unpatch = after("render", ChatInput.prototype, (_, ret) => { + unpatchGift = after("render", ChatInputGift.ChatInput.prototype, (_, ret) => { + const states = findInReactTree(ret, t => + typeof t.props?.hideGiftButton === "boolean" + ); + states.props.hideGiftButton = true; + }); + unpatchThreads = after("render", ChatInputThreads.prototype, (_, ret) => { const input = findInReactTree(ret, t => "forceAnimateButtons" in t.props && t.props.actions); input.props.actions = input.props.actions.filter(a => !blockList.includes(a.source)); }); }, - onUnload: unpatch + onUnload: unpatchGift, unpatchThreads };