Skip to content

Commit

Permalink
ditch state spoofing and use actaul id instead of asset name
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed Jul 5, 2024
1 parent 5586bd2 commit 22ef5eb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plugins/HideGiftButton/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
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");
Expand All @@ -9,15 +8,16 @@ let unpatch: () => boolean;

export default {
onLoad() {
ChatInput.defaultProps.hideGiftButton = true;
const blockList = ["ic_thread_normal_24px", "ic_gift"].map(n => getAssetIDByName(n));
// 332 - ic_thread_normal_24px
// 269 - ic_gift
// getAssetIDByName gives 369 which is also ic_gift but not that used in ChatInput
const blockList = [332, 269];
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;
unpatch();
}
};

0 comments on commit 22ef5eb

Please sign in to comment.