diff --git a/src/plugins/_api/messageEvents.ts b/src/plugins/_api/messageEvents.ts index 25a46711d..9dfc55e27 100644 --- a/src/plugins/_api/messageEvents.ts +++ b/src/plugins/_api/messageEvents.ts @@ -37,13 +37,9 @@ export default definePlugin({ { find: ".handleSendMessage,onResize", replacement: { - // FIXME: Simplify this change once all branches share the same code - // props.chatInputType...then((function(isMessageValid)... var parsedMessage = b.c.parse(channel,... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); - // Lookbehind: validateMessage)({openWarningPopout:..., type: i.props.chatInputType, content: t, stickers: r, ...}).then((function(isMessageValid) - match: /(\{openWarningPopout:.{0,100}type:this.props.chatInputType.+?\.then\((?:async )?)(\i=>\{.+?let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);)(?<=\)\(({.+?})\)\.then.+?)/, - // props.chatInputType...then((async function(isMessageValid)... var replyOptions = f.g.getSendMessageOptionsForReply(pendingReply); if(await Vencord.api...) return { shoudClear:true, shouldRefocus:true }; - replace: (_, rest1, rest2, parsedMessage, channel, replyOptions, extra) => "" + - `${rest1}${rest1.includes("async") ? "" : "async "}${rest2}` + + // https://regex101.com/r/hBlXpl/1 + match: /let (\i)=\i\.\i\.parse\((\i),.+?let (\i)=\i\.\i\.getSendMessageOptions\(\{.+?\}\);(?<=\)\(({.+?})\)\.then.+?)/, + replace: (m, parsedMessage, channel, replyOptions, extra) => m + `if(await Vencord.Api.MessageEvents._handlePreSend(${channel}.id,${parsedMessage},${extra},${replyOptions}))` + "return{shouldClear:false,shouldRefocus:true};" } @@ -53,8 +49,7 @@ export default definePlugin({ replacement: { match: /let\{id:\i}=(\i),{id:\i}=(\i);return \i\.useCallback\((\i)=>\{/, replace: (m, message, channel, event) => - // the message param is shadowed by the event param, so need to alias them - `const vcMsg=${message},vcChan=${channel};${m}Vencord.Api.MessageEvents._handleClick(vcMsg, vcChan, ${event});` + `const vcMsg=${message},vcChan=${channel};${m}Vencord.Api.MessageEvents._handleClick(vcMsg,vcChan,${event});` } } ] diff --git a/src/plugins/fullUserInChatbox/index.tsx b/src/plugins/fullUserInChatbox/index.tsx index 5a0c41c01..ceeb56926 100644 --- a/src/plugins/fullUserInChatbox/index.tsx +++ b/src/plugins/fullUserInChatbox/index.tsx @@ -8,6 +8,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin from "@utils/types"; import { findComponentByCodeLazy } from "@webpack"; +import { UserStore, useStateFromStores } from "@webpack/common"; import { ReactNode } from "react"; const UserMentionComponent = findComponentByCodeLazy(".USER_MENTION)"); @@ -34,14 +35,19 @@ export default definePlugin({ } ], - UserMentionComponent: ErrorBoundary.wrap((props: UserMentionComponentProps) => ( - { + const user = useStateFromStores([UserStore], () => UserStore.getUser(props.id)); + if (user == null) { + return props.originalComponent(); + } + + return - ), { + />; + }, { fallback: ({ wrappedProps: { originalComponent } }) => originalComponent() }) }); diff --git a/src/plugins/implicitRelationships/index.ts b/src/plugins/implicitRelationships/index.ts index c6b61ef4a..cfc3818dd 100644 --- a/src/plugins/implicitRelationships/index.ts +++ b/src/plugins/implicitRelationships/index.ts @@ -50,9 +50,9 @@ export default definePlugin({ { find: "#{intl::FRIENDS_SECTION_ONLINE}", replacement: { - match: /(\(0,\i\.jsx\)\(\i\.\i\.Item,\{id:\i\.\i)\.BLOCKED,className:([^\s]+?)\.item,children:\i\.\i\.string\(\i\.\i#{intl::BLOCKED}\)\}\)/, - replace: "$1.IMPLICIT,className:$2.item,children:\"Implicit\"}),$&" - }, + match: /,{id:(\i\.\i)\.BLOCKED,show:.+?className:(\i\.item)/, + replace: (rest, relationShipTypes, className) => `,{id:${relationShipTypes}.IMPLICIT,show:true,className:${className},content:"Implicit"}${rest}` + } }, // Sections content { diff --git a/src/plugins/ircColors/index.ts b/src/plugins/ircColors/index.ts index a518fd93d..af926043d 100644 --- a/src/plugins/ircColors/index.ts +++ b/src/plugins/ircColors/index.ts @@ -41,13 +41,25 @@ const settings = definePluginSettings({ restartNeeded: true, type: OptionType.BOOLEAN, default: true + }, + applyColorOnlyToUsersWithoutColor: { + description: "Apply colors only to users who don't have a predefined color", + restartNeeded: false, + type: OptionType.BOOLEAN, + default: false + }, + applyColorOnlyInDms: { + description: "Apply colors only in direct messages; do not apply colors in servers.", + restartNeeded: false, + type: OptionType.BOOLEAN, + default: false } }); export default definePlugin({ name: "IrcColors", description: "Makes username colors in chat unique, like in IRC clients", - authors: [Devs.Grzesiek11], + authors: [Devs.Grzesiek11, Devs.jamesbt365], settings, patches: [ @@ -70,10 +82,28 @@ export default definePlugin({ calculateNameColorForMessageContext(context: any) { const id = context?.message?.author?.id; - return calculateNameColorForUser(id); + const colorString = context?.author?.colorString; + const color = calculateNameColorForUser(id); + + if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) { + return colorString; + } + + return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) + ? color + : colorString; }, calculateNameColorForListContext(context: any) { const id = context?.user?.id; - return calculateNameColorForUser(id); + const colorString = context?.colorString; + const color = calculateNameColorForUser(id); + + if (settings.store.applyColorOnlyInDms && !context?.channel?.isPrivate()) { + return colorString; + } + + return (!settings.store.applyColorOnlyToUsersWithoutColor || !colorString) + ? color + : colorString; } }); diff --git a/src/plugins/notificationVolume/index.ts b/src/plugins/notificationVolume/index.ts index bc3c7539d..d320d76f1 100644 --- a/src/plugins/notificationVolume/index.ts +++ b/src/plugins/notificationVolume/index.ts @@ -25,9 +25,9 @@ export default definePlugin({ settings, patches: [ { - find: "_ensureAudio(){", + find: "ensureAudio(){", replacement: { - match: /(?=Math\.min\(\i\.\i\.getOutputVolume\(\)\/100)/, + match: /(?=Math\.min\(\i\.\i\.getOutputVolume\(\)\/100)/g, replace: "$self.settings.store.notificationVolume/100*" }, },