Fix Broken Patch + Remove @ From MentionAvatars

This commit is contained in:
thororen1234 2024-07-25 20:37:31 -04:00
parent 9a0acbd72d
commit cdba643226
2 changed files with 20 additions and 7 deletions

View file

@ -6,17 +6,25 @@
import "./styles.css";
import { definePluginSettings } from "@api/Settings";
import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants";
import definePlugin from "@utils/types";
import definePlugin, { OptionType } from "@utils/types";
import { SelectedGuildStore, useState } from "@webpack/common";
import { User } from "discord-types/general";
export const settings = definePluginSettings({
hideAtSymbol: {
type: OptionType.BOOLEAN,
description: "Whether the the @-symbol should be hidden.",
default: true
}
});
export default definePlugin({
name: "MentionAvatars",
description: "Shows user avatars inside mentions",
authors: [Devs.Ven],
authors: [Devs.Ven, Devs.Luna],
patches: [{
find: ".USER_MENTION)",
replacement: {
@ -24,12 +32,12 @@ export default definePlugin({
replace: "children:$self.renderUsername({username:$1,user:$2})"
}
}],
settings,
renderUsername: ErrorBoundary.wrap((props: { user: User, username: string; }) => {
const { user, username } = props;
const [isHovering, setIsHovering] = useState(false);
if (!user) return <>@{username}</>;
if (!user) return <>{getUsernameString(username)}</>;
return (
<span
@ -37,8 +45,13 @@ export default definePlugin({
onMouseLeave={() => setIsHovering(false)}
>
<img src={user.getAvatarURL(SelectedGuildStore.getGuildId(), 16, isHovering)} className="vc-mentionAvatars-avatar" />
@{username}
{getUsernameString(username)}
</span>
);
}, { noop: true })
});
function getUsernameString(username: string) {
if (settings.store.hideAtSymbol) return username;
return `@${username}`;
}

View file

@ -307,7 +307,7 @@ export default definePlugin({
]
},
{
find: '+1]})},"overflow"))',
find: '})},"overflow"))',
replacement: [
{
// Create a variable for the channel prop