Fix broken patches
This commit is contained in:
parent
09c6c16cf9
commit
e437498c8f
4 changed files with 9 additions and 10 deletions
|
@ -18,14 +18,14 @@
|
|||
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { Channel, Message } from "discord-types/general";
|
||||
import type { MouseEventHandler } from "react";
|
||||
import type { ComponentType, MouseEventHandler, ReactElement } from "react";
|
||||
|
||||
const logger = new Logger("MessagePopover");
|
||||
|
||||
export interface ButtonItem {
|
||||
key?: string,
|
||||
label: string,
|
||||
icon: React.ComponentType<any>,
|
||||
icon: ComponentType<any>,
|
||||
message: Message,
|
||||
channel: Channel,
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>,
|
||||
|
@ -49,16 +49,16 @@ export function removeButton(identifier: string) {
|
|||
|
||||
export function _buildPopoverElements(
|
||||
msg: Message,
|
||||
makeButton: (item: ButtonItem) => React.ComponentType
|
||||
PopoverButton: ComponentType<ButtonItem>,
|
||||
) {
|
||||
const items = [] as React.ComponentType[];
|
||||
const items = [] as ReactElement[];
|
||||
|
||||
for (const [identifier, getItem] of buttons.entries()) {
|
||||
try {
|
||||
const item = getItem(msg);
|
||||
if (item) {
|
||||
item.key ??= identifier;
|
||||
items.push(makeButton(item));
|
||||
items.push(<PopoverButton {...item} />);
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error(`[${identifier}]`, err);
|
|
@ -26,9 +26,8 @@ export default definePlugin({
|
|||
patches: [{
|
||||
find: "Messages.MESSAGE_UTILITIES_A11Y_LABEL",
|
||||
replacement: {
|
||||
// foo && !bar ? createElement(reactionStuffs)... createElement(blah,...makeElement(reply-other))
|
||||
match: /\i&&!\i\?\(0,\i\.jsxs?\)\(.{0,200}renderEmojiPicker:.{0,500}\?(\i)\(\{key:"reply-other"(?<=message:(\i).+?)/,
|
||||
replace: (m, makeElement, msg) => `...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${makeElement}),${m}`
|
||||
match: /"reply-self".+?Fragment,{children:\[(?=.+?\((\i\.\i),{label:)(?<=message:(\i).+?)/,
|
||||
replace: (m, PopoverButton, msg) => `${m}...Vencord.Api.MessagePopover._buildPopoverElements(${msg},${PopoverButton}),`
|
||||
}
|
||||
}],
|
||||
});
|
||||
|
|
|
@ -27,7 +27,7 @@ export default definePlugin({
|
|||
authors: [Devs.D3SOX, Devs.Nickyux],
|
||||
patches: [
|
||||
{
|
||||
find: ".PREMIUM_GUILD_SUBSCRIPTION_TOOLTIP",
|
||||
find: ".Messages.GUILD_OWNER,",
|
||||
replacement: {
|
||||
match: /,isOwner:(\i),/,
|
||||
replace: ",_isOwner:$1=$self.isGuildOwner(e),"
|
||||
|
|
|
@ -311,7 +311,7 @@ export default definePlugin({
|
|||
replacement: [
|
||||
{
|
||||
// Create a variable for the channel prop
|
||||
match: /maxUsers:\i,users:\i.+?}=(\i).*?;/,
|
||||
match: /users:\i,maxUsers:\i.+?}=(\i).*?;/,
|
||||
replace: (m, props) => `${m}let{shcChannel}=${props};`
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue