Skip to content

Commit

Permalink
more reliable approch?
Browse files Browse the repository at this point in the history
  • Loading branch information
Rico040 committed May 3, 2024
1 parent 94e89af commit da4b301
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions plugins/hideappbutton/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { logger } from "@vendetta";
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");

let unpatch: () => boolean;
const patch = after("render", ChatInput.prototype, (...args) => {
try {
args[1].props.children[2].props.children.props.children[1].props.isAppLauncherEnabled = false;
} catch (e) {
logger.error("Failed to hide voice message button", e);
}
});

export default {
onLoad() {
const blockList = ["ic_thread_normal_24px", "AppsIcon"].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: unpatch
};
export const onUnload = () => patch();

0 comments on commit da4b301

Please sign in to comment.