diff options
author | Vendicated <vendicated@riseup.net> | 2023-02-12 21:06:49 +0100 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2023-02-12 21:07:05 +0100 |
commit | c154965d7072179cca3933bb5f387f8ae1d6711b (patch) | |
tree | e98f81e8017bf047129a42e77af9c5eff2e8d2a8 /src | |
parent | 614234ad208963a8068b156fd04760be6013a554 (diff) | |
download | Vencord-c154965d7072179cca3933bb5f387f8ae1d6711b.tar.gz Vencord-c154965d7072179cca3933bb5f387f8ae1d6711b.tar.bz2 Vencord-c154965d7072179cca3933bb5f387f8ae1d6711b.zip |
TypingTweaks: Fix crash after changing language
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/typingTweaks.tsx | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/plugins/typingTweaks.tsx b/src/plugins/typingTweaks.tsx index f03779c..4548179 100644 --- a/src/plugins/typingTweaks.tsx +++ b/src/plugins/typingTweaks.tsx @@ -22,6 +22,7 @@ import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; import { findByCodeLazy } from "@webpack"; import { GuildMemberStore, React, RelationshipStore } from "@webpack/common"; +import { User } from "discord-types/general"; const Avatar = findByCodeLazy(".Positions.TOP,spacing:"); @@ -64,36 +65,28 @@ export default definePlugin({ replace: "return $1" } }, - // Changes indicator to format message with the typing users - { - find: '"SEVERAL_USERS_TYPING":"', - replacement: { - match: /("SEVERAL_USERS_TYPING"):".+?"/, - replace: "$1:\"**!!{a}!!**, **!!{b}!!**, and {c} others are typing...\"" - }, - predicate: () => settings.store.alternativeFormatting - }, - { - find: ",\"SEVERAL_USERS_TYPING\",\"", - replacement: { - match: /(?<="SEVERAL_USERS_TYPING",)".+?"/, - replace: '"**!!{a}!!**, **!!{b}!!**, and {c} others are typing..."' - }, - predicate: () => settings.store.alternativeFormatting - }, // Adds the alternative formatting for several users typing { find: "getCooldownTextStyle", replacement: { - match: /(\i)\.length\?.\..\.Messages\.THREE_USERS_TYPING.format\(\{a:(\i),b:(\i),c:.}\).+?SEVERAL_USERS_TYPING/, - replace: "$&.format({a:$2,b:$3,c:$1.length-2})" + match: /((\i)\.length\?.\..\.Messages\.THREE_USERS_TYPING.format\(\{a:(\i),b:(\i),c:.}\)):.+?SEVERAL_USERS_TYPING/, + replace: "$1:$self.buildSeveralUsers({a:$3,b:$4,c:$2.length-2})" }, predicate: () => settings.store.alternativeFormatting } ], settings, - mutateChildren(props, users, children) { + buildSeveralUsers({ a, b, c }: { a: string, b: string, c: number; }) { + return [ + <strong key="0">{a}</strong>, + ", ", + <strong key="2">{b}</strong>, + `, and ${c} others are typing...` + ]; + }, + + mutateChildren(props: any, users: User[], children: any) { if (!Array.isArray(children)) return children; let element = 0; @@ -101,7 +94,7 @@ export default definePlugin({ return children.map(c => c.type === "strong" ? <this.TypingUser {...props} user={users[element++]} /> : c); }, - TypingUser: ErrorBoundary.wrap(({ user, guildId }) => { + TypingUser: ErrorBoundary.wrap(({ user, guildId }: { user: User, guildId: string; }) => { return <strong style={{ display: "grid", gridAutoFlow: "column", |