TypingIndicator: fix TypingTweaks compatibility
This commit is contained in:
parent
23eb85e898
commit
43ba1a4a5e
3 changed files with 13 additions and 11 deletions
|
|
@ -44,7 +44,6 @@ const getToken = async () => {
|
|||
return token;
|
||||
};
|
||||
|
||||
getToken().then(console.log);
|
||||
async function fetchRemoteData({ id, name, artist, album }: { id: string, name: string, artist: string, album: string; }) {
|
||||
if (id === cachedRemoteData?.id) {
|
||||
if ("data" in cachedRemoteData) return cachedRemoteData.data;
|
||||
|
|
|
|||
|
|
@ -69,26 +69,29 @@ function TypingIndicator({ channelId, guildId }: { channelId: string; guildId: s
|
|||
|
||||
const myId = UserStore.getCurrentUser()?.id;
|
||||
|
||||
const typingUsersArray = Object.keys(typingUsers).filter(id => id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers));
|
||||
const typingUsersArray = Object.keys(typingUsers).filter(id =>
|
||||
id !== myId && !(RelationshipStore.isBlocked(id) && !settings.store.includeBlockedUsers)
|
||||
);
|
||||
const [a, b, c] = typingUsersArray;
|
||||
let tooltipText: string;
|
||||
|
||||
switch (typingUsersArray.length) {
|
||||
case 0: break;
|
||||
case 1: {
|
||||
tooltipText = getIntlMessage("ONE_USER_TYPING", { a: getDisplayName(guildId, typingUsersArray[0]) });
|
||||
tooltipText = getIntlMessage("ONE_USER_TYPING", { a: getDisplayName(guildId, a) });
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
tooltipText = getIntlMessage("TWO_USERS_TYPING", { a: getDisplayName(guildId, typingUsersArray[0]), b: getDisplayName(guildId, typingUsersArray[1]) });
|
||||
tooltipText = getIntlMessage("TWO_USERS_TYPING", { a: getDisplayName(guildId, a), b: getDisplayName(guildId, b) });
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
tooltipText = getIntlMessage("THREE_USERS_TYPING", { a: getDisplayName(guildId, typingUsersArray[0]), b: getDisplayName(guildId, typingUsersArray[1]), c: getDisplayName(guildId, typingUsersArray[2]) });
|
||||
tooltipText = getIntlMessage("THREE_USERS_TYPING", { a: getDisplayName(guildId, a), b: getDisplayName(guildId, b), c: getDisplayName(guildId, c) });
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
tooltipText = Settings.plugins.TypingTweaks.enabled
|
||||
? buildSeveralUsers({ a: getDisplayName(guildId, typingUsersArray[0]), b: getDisplayName(guildId, typingUsersArray[1]), count: typingUsersArray.length - 2 })
|
||||
? buildSeveralUsers({ a: UserStore.getUser(a), b: UserStore.getUser(b), count: typingUsersArray.length - 2, guildId })
|
||||
: getIntlMessage("SEVERAL_USERS_TYPING");
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 { Channel, User } from "discord-types/general";
|
||||
import { User } from "discord-types/general";
|
||||
import { PropsWithChildren } from "react";
|
||||
|
||||
import managedStyle from "./style.css?managed";
|
||||
|
|
@ -45,12 +45,12 @@ const settings = definePluginSettings({
|
|||
}
|
||||
});
|
||||
|
||||
export const buildSeveralUsers = ErrorBoundary.wrap(({ a, b, count, channel }: { a: User, b: User, count: number; channel: Channel; }) => {
|
||||
export const buildSeveralUsers = ErrorBoundary.wrap(({ a, b, count, guildId }: { a: User, b: User, count: number; guildId: string; }) => {
|
||||
return (
|
||||
<>
|
||||
<TypingUser user={a} guildId={channel.guild_id} />
|
||||
<TypingUser user={a} guildId={guildId} />
|
||||
{", "}
|
||||
<TypingUser user={b} guildId={channel.guild_id} />
|
||||
<TypingUser user={b} guildId={guildId} />
|
||||
{", "}
|
||||
and {count} others are typing...
|
||||
</>
|
||||
|
|
@ -115,7 +115,7 @@ 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, channel: arguments[0]?.channel })`,
|
||||
`${rest}$self.buildSeveralUsers({ a: ${a}, b: ${b}, count: ${users}.length - 2, channel: arguments[0]?.channel?.guild_id })`,
|
||||
predicate: () => settings.store.alternativeFormatting
|
||||
}
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue