Fix PinDMs, SMYN, SilentTyping, ValidUser, PlatformIndicators (#1865)

This commit is contained in:
rini 2023-10-25 12:34:23 -03:00 committed by V
parent c5dd50ad8f
commit 9c60b38acc
6 changed files with 34 additions and 56 deletions

View file

@ -21,14 +21,11 @@ import { Devs } from "@utils/constants";
import { sleep } from "@utils/misc";
import { Queue } from "@utils/Queue";
import definePlugin from "@utils/types";
import { findByCodeLazy } from "@webpack";
import { UserStore, useState } from "@webpack/common";
import type { User } from "discord-types/general";
import { UserStore, UserUtils, useState } from "@webpack/common";
import type { ComponentType, ReactNode } from "react";
const fetching = new Set<string>();
const queue = new Queue(5);
const fetchUser = findByCodeLazy("USER(") as (id: string) => Promise<User>;
interface MentionProps {
data: {
@ -88,7 +85,7 @@ function MentionWrapper({ data, UserMention, RoleMention, parse, props }: Mentio
fetching.add(id);
queue.unshift(() =>
fetchUser(id)
UserUtils.getUser(id)
.then(() => {
setUserId(id);
fetching.delete(id);
@ -122,9 +119,9 @@ export default definePlugin({
find: 'className:"mention"',
replacement: {
// mention = { react: function (data, parse, props) { if (data.userId == null) return RoleMention() else return UserMention()
match: /react:(?=function\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i),.+?jsx\)\((\i),\{className:"mention")/,
match: /react(?=\(\i,\i,\i\).{0,50}return null==\i\?\(0,\i\.jsx\)\((\i\.\i),.+?jsx\)\((\i\.\i),\{className:"mention")/,
// react: (...args) => OurWrapper(RoleMention, UserMention, ...args), originalReact: theirFunc
replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact:"
replace: "react:(...args)=>$self.renderMention($1,$2,...args),originalReact"
}
}],