forked from pylixonly/letup
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HideGiftButton: spoof hide gift state
- Loading branch information
Showing
1 changed file
with
13 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}; |