fix userutils (#1861)
This commit is contained in:
parent
788d22f9e9
commit
2478ffb695
@ -94,7 +94,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
|
||||
(async () => {
|
||||
for (const user of plugin.authors.slice(0, 6)) {
|
||||
const author = user.id
|
||||
? await UserUtils.fetchUser(`${user.id}`)
|
||||
? await UserUtils.getUser(`${user.id}`)
|
||||
.catch(() => makeDummyUser({ username: user.name }))
|
||||
: makeDummyUser({ username: user.name });
|
||||
|
||||
|
@ -37,7 +37,7 @@ export async function onRelationshipRemove({ relationship: { type, id } }: Relat
|
||||
return;
|
||||
}
|
||||
|
||||
const user = await UserUtils.fetchUser(id)
|
||||
const user = await UserUtils.getUser(id)
|
||||
.catch(() => null);
|
||||
if (!user) return;
|
||||
|
||||
|
@ -68,7 +68,7 @@ export async function syncAndRunChecks() {
|
||||
for (const id of oldFriends.friends) {
|
||||
if (friends.friends.includes(id)) continue;
|
||||
|
||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||
const user = await UserUtils.getUser(id).catch(() => void 0);
|
||||
if (user)
|
||||
notify(
|
||||
`You are no longer friends with ${getUniqueUsername(user)}.`,
|
||||
@ -85,7 +85,7 @@ export async function syncAndRunChecks() {
|
||||
[RelationshipType.FRIEND, RelationshipType.BLOCKED, RelationshipType.OUTGOING_REQUEST].includes(RelationshipStore.getRelationshipType(id))
|
||||
) continue;
|
||||
|
||||
const user = await UserUtils.fetchUser(id).catch(() => void 0);
|
||||
const user = await UserUtils.getUser(id).catch(() => void 0);
|
||||
if (user)
|
||||
notify(
|
||||
`Friend request from ${getUniqueUsername(user)} has been revoked.`,
|
||||
|
@ -162,7 +162,7 @@ function Owner(guildId: string, owner: User) {
|
||||
}
|
||||
|
||||
function ServerInfoTab({ guild }: GuildProps) {
|
||||
const [owner] = useAwaiter(() => UserUtils.fetchUser(guild.ownerId), {
|
||||
const [owner] = useAwaiter(() => UserUtils.getUser(guild.ownerId), {
|
||||
deps: [guild.ownerId],
|
||||
fallbackValue: null
|
||||
});
|
||||
|
@ -103,7 +103,7 @@ export function openImageModal(url: string, props?: Partial<React.ComponentProps
|
||||
const openProfile = findByCodeLazy("friendToken", "USER_PROFILE_MODAL_OPEN");
|
||||
|
||||
export async function openUserProfile(id: string) {
|
||||
const user = await UserUtils.fetchUser(id);
|
||||
const user = await UserUtils.getUser(id);
|
||||
if (!user) throw new Error("No such user: " + id);
|
||||
|
||||
const guildId = SelectedGuildStore.getGuildId();
|
||||
|
@ -20,7 +20,7 @@ import { proxyLazy } from "@utils/lazy";
|
||||
import type { User } from "discord-types/general";
|
||||
|
||||
// eslint-disable-next-line path-alias/no-relative
|
||||
import { _resolveReady, filters, find, findByCodeLazy, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack";
|
||||
import { _resolveReady, filters, find, findByPropsLazy, findLazy, mapMangledModuleLazy, waitFor } from "../webpack";
|
||||
import type * as t from "./types/utils";
|
||||
|
||||
export let FluxDispatcher: t.FluxDispatcher;
|
||||
@ -91,9 +91,7 @@ export function showToast(message: string, type = ToastType.MESSAGE) {
|
||||
});
|
||||
}
|
||||
|
||||
export const UserUtils = {
|
||||
fetchUser: findByCodeLazy(".USER(", "getUser") as (id: string) => Promise<User>,
|
||||
};
|
||||
export const UserUtils = findByPropsLazy("getUser", "fetchCurrentUser") as { getUser: (id: string) => Promise<User>; };
|
||||
|
||||
export const Clipboard = mapMangledModuleLazy('document.queryCommandEnabled("copy")||document.queryCommandSupported("copy")', {
|
||||
copy: filters.byCode(".copy("),
|
||||
|
Loading…
x
Reference in New Issue
Block a user