TypingTweaks: fix several users are typing display

This commit is contained in:
Vendicated 2025-07-01 22:57:22 +02:00
parent 18274e4f0e
commit 1b2bc07592
No known key found for this signature in database
GPG key ID: D66986BAF75ECF18

View file

@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
import { openUserProfile } from "@utils/discord"; import { openUserProfile } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types"; import definePlugin, { OptionType } from "@utils/types";
import { Avatar, GuildMemberStore, React, RelationshipStore } from "@webpack/common"; import { Avatar, GuildMemberStore, React, RelationshipStore } from "@webpack/common";
import { User } from "discord-types/general"; import { Channel, User } from "discord-types/general";
import { PropsWithChildren } from "react"; import { PropsWithChildren } from "react";
import managedStyle from "./style.css?managed"; import managedStyle from "./style.css?managed";
@ -45,13 +45,14 @@ const settings = definePluginSettings({
} }
}); });
export const buildSeveralUsers = ErrorBoundary.wrap(({ a, b, count }: { a: string, b: string, count: number; }) => { export const buildSeveralUsers = ErrorBoundary.wrap(({ a, b, count, channel }: { a: User, b: User, count: number; channel: Channel; }) => {
return ( return (
<> <>
<strong key="0">{a}</strong>, <TypingUser user={a} guildId={channel.guild_id} />
", ", {", "}
<strong key="1">{b}</strong>, <TypingUser user={b} guildId={channel.guild_id} />
`, and ${count} others are typing...` {", "}
and {count} others are typing...
</> </>
); );
}, { noop: true }); }, { noop: true });
@ -113,7 +114,8 @@ export default definePlugin({
{ {
// Adds the alternative formatting for several users typing // Adds the alternative formatting for several users typing
match: /(,{a:(\i),b:(\i),c:\i}\):\i\.length>3&&\(\i=)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/, match: /(,{a:(\i),b:(\i),c:\i}\):\i\.length>3&&\(\i=)\i\.\i\.string\(\i\.\i#{intl::SEVERAL_USERS_TYPING}\)(?<=(\i)\.length.+?)/,
replace: (_, rest, a, b, users) => `${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2 })`, replace: (_, rest, a, b, users) =>
`${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2, channel: arguments[0]?.channel })`,
predicate: () => settings.store.alternativeFormatting predicate: () => settings.store.alternativeFormatting
} }
] ]