TypingTweaks: fix several users are typing display
This commit is contained in:
parent
18274e4f0e
commit
1b2bc07592
1 changed files with 9 additions and 7 deletions
|
|
@ -22,7 +22,7 @@ import { Devs } from "@utils/constants";
|
|||
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 { Channel, User } from "discord-types/general";
|
||||
import { PropsWithChildren } from "react";
|
||||
|
||||
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 (
|
||||
<>
|
||||
<strong key="0">{a}</strong>,
|
||||
", ",
|
||||
<strong key="1">{b}</strong>,
|
||||
`, and ${count} others are typing...`
|
||||
<TypingUser user={a} guildId={channel.guild_id} />
|
||||
{", "}
|
||||
<TypingUser user={b} guildId={channel.guild_id} />
|
||||
{", "}
|
||||
and {count} others are typing...
|
||||
</>
|
||||
);
|
||||
}, { noop: true });
|
||||
|
|
@ -113,7 +114,8 @@ export default definePlugin({
|
|||
{
|
||||
// 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.+?)/,
|
||||
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
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue