Hide threads in HideGiftButton

This commit is contained in:
amsyarasyiq 2023-08-21 02:52:51 +08:00
parent 1843ff4e38
commit b36ff42d59

View file

@ -1,16 +1,19 @@
import { findByName } from "@vendetta/metro";
import { after } from "@vendetta/patcher";
import { getAssetIDByName } from "@vendetta/ui/assets";
import { findInReactTree } from "@vendetta/utils";
const ChatInput = findByName("ChatInput");
// Object.defineProperty(ChatInput.defaultProps, "hideGiftButton", {
// get: () => plugins?.[plugin.id]?.enabled
// });
let unpatch: () => boolean;
export default {
onLoad() {
ChatInput.defaultProps.hideGiftButton = true;
const blockList = ["ic_thread_normal_24px", "ic_gift"].map(n => getAssetIDByName(n));
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() {
ChatInput.defaultProps.hideGiftButton = false;
}
onUnload: unpatch
};