Skip to content

Commit

Permalink
typingTweaks: wrap in ErrorBoundary
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed Dec 19, 2024
1 parent 33bca8e commit 7f8ee65
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/plugins/typingTweaks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { openUserProfile } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { Avatar, GuildMemberStore, React, RelationshipStore } from "@webpack/common";
import { User } from "discord-types/general";
import { PropsWithChildren } from "react";

const settings = definePluginSettings({
showAvatars: {
Expand Down Expand Up @@ -100,7 +101,7 @@ export default definePlugin({
{
// Style the indicator and add function call to modify the children before rendering
match: /(?<=children:\[(\i)\.length>0.{0,200}?"aria-atomic":!0,children:)\i(?<=guildId:(\i).+?)/,
replace: "$self.mutateChildren($2,$1,$&),style:$self.TYPING_TEXT_STYLE"
replace: "$self.renderTypingUsers({ users: $1, guildId: $2, children: $& }),style:$self.TYPING_TEXT_STYLE"
},
{
// Changes the indicator to keep the user object when creating the list of typing users
Expand All @@ -125,7 +126,7 @@ export default definePlugin({

buildSeveralUsers,

mutateChildren(guildId: any, users: User[], children: any) {
renderTypingUsers: ErrorBoundary.wrap(({ guildId, users, children }: PropsWithChildren<{ guildId: string, users: User[]; }>) => {
try {
if (!Array.isArray(children)) {
return children;
Expand All @@ -145,5 +146,5 @@ export default definePlugin({
}

return children;
}
}, { noop: true })
});

0 comments on commit 7f8ee65

Please sign in to comment.