Skip to content

Commit

Permalink
refactor lmao
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed Jul 4, 2024
1 parent 9f91cce commit 5c5d9aa
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions plugins/HideGiftButton/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { findByName, findByProps } from "@vendetta/metro";
import { findByName } from "@vendetta/metro";
import { after } from "@vendetta/patcher";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { findInReactTree } from "@vendetta/utils";

const ChatInputGift = findByProps("ChatInput");
const ChatInputThreads = findByName("ChatInput");
const ChatInput = findByName("ChatInput");

let unpatchGift: () => boolean;
let unpatchThreads: () => boolean;
let unpatch: () => boolean;

export default {
onLoad() {
ChatInput.defaultProps.hideGiftButton = true;
const blockList = ["ic_thread_normal_24px", "ic_gift"].map(n => getAssetIDByName(n));
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) => {
unpatch = after("render", ChatInput.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: unpatchGift, unpatchThreads
onUnload: unpatch
};

0 comments on commit 5c5d9aa

Please sign in to comment.