ChatInputButtonAPI: fix patch and class finds
This commit is contained in:
parent
c565c3b72b
commit
b16133d122
3 changed files with 9 additions and 40 deletions
|
|
@ -2,29 +2,3 @@
|
|||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/* FIXME: bad name
|
||||
_7f7a2c5f23327d73 */
|
||||
.vc-chatbar-discord-button {
|
||||
opacity: .7;
|
||||
align-items: center;
|
||||
align-self: center;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
padding: 10px;
|
||||
|
||||
&:hover {
|
||||
background: hsl(0deg 0% 100% / 10%);
|
||||
opacity: 1
|
||||
}
|
||||
}
|
||||
|
||||
/* _3f4f204c3133fb93 */
|
||||
.vc-chatbar-button-wrapper {
|
||||
align-self: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
gap: 8px;
|
||||
}
|
||||
|
|
@ -7,22 +7,19 @@
|
|||
import "./ChatButton.css";
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { classNameFactory } from "@utils/css";
|
||||
import { Logger } from "@utils/Logger";
|
||||
import { classes } from "@utils/misc";
|
||||
import { IconComponent } from "@utils/types";
|
||||
import { Channel } from "@vencord/discord-types";
|
||||
import { waitFor } from "@webpack";
|
||||
import { findCssClassesLazy } from "@webpack";
|
||||
import { Clickable, Menu, Tooltip } from "@webpack/common";
|
||||
import { HTMLProps, JSX, MouseEventHandler, ReactNode } from "react";
|
||||
|
||||
import { addContextMenuPatch, findGroupChildrenByChildId } from "./ContextMenu";
|
||||
import { useSettings } from "./Settings";
|
||||
|
||||
const cl = classNameFactory("vc-chatbar-");
|
||||
|
||||
let ChannelTextAreaClasses: Record<"button" | "buttonContainer", string>;
|
||||
waitFor(["buttonContainer", "channelTextArea"], m => ChannelTextAreaClasses = m);
|
||||
const ButtonWrapperClasses = findCssClassesLazy("button", "buttonWrapper", "notificationDot");
|
||||
const ChannelTextAreaClasses = findCssClassesLazy("buttonContainer", "channelTextArea", "button");
|
||||
|
||||
export interface ChatBarProps {
|
||||
channel: Channel;
|
||||
|
|
@ -116,11 +113,9 @@ function VencordChatBarButtons(props: ChatBarProps) {
|
|||
}
|
||||
|
||||
export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) {
|
||||
if (props.disabled) return;
|
||||
if (props.disabled || buttons.length === 0) return;
|
||||
|
||||
buttons.unshift(<VencordChatBarButtons key="vencord-chat-buttons" {...props} />);
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -143,18 +138,18 @@ export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => {
|
|||
return (
|
||||
<Tooltip text={props.tooltip}>
|
||||
{({ onMouseEnter, onMouseLeave }) => (
|
||||
<div className={`expression-picker-chat-input-button ${ChannelTextAreaClasses?.buttonContainer ?? ""} ${cl("button")}`}>
|
||||
<div className={`expression-picker-chat-input-button ${ChannelTextAreaClasses?.buttonContainer ?? ""} vc-chatbar-button`}>
|
||||
<Clickable
|
||||
aria-label={props.tooltip}
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
className={classes(cl("discord-button"), ChannelTextAreaClasses?.button)}
|
||||
className={classes(ButtonWrapperClasses.button, ChannelTextAreaClasses?.button)}
|
||||
onClick={props.onClick}
|
||||
onContextMenu={props.onContextMenu}
|
||||
onAuxClick={props.onAuxClick}
|
||||
{...props.buttonProps}
|
||||
>
|
||||
<div className={cl("button-wrapper")}>
|
||||
<div className={ButtonWrapperClasses.buttonWrapper}>
|
||||
{props.children}
|
||||
</div>
|
||||
</Clickable>
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ export default definePlugin({
|
|||
{
|
||||
find: '"sticker")',
|
||||
replacement: {
|
||||
match: /(?<=className:.{0,20}\.buttons.{0,50}children:)(\i)/,
|
||||
replace: "Vencord.Api.ChatButtons._injectButtons($1,arguments[0])"
|
||||
match: /(?<=let (\i)=\(0,\i\.chain\).+?;)(?=return)/,
|
||||
replace: "Vencord.Api.ChatButtons._injectButtons($1,arguments[0]);"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue