From 3f0cedc501918bd82782cebb921e801646fb4a0e Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Fri, 24 Apr 2026 13:34:31 -0300 Subject: [PATCH] Fix Toasts and ServerInfo Friends tab --- src/plugins/serverInfo/GuildInfoModal.tsx | 2 +- src/webpack/common/utils.ts | 38 ++++++++++++++--------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/plugins/serverInfo/GuildInfoModal.tsx b/src/plugins/serverInfo/GuildInfoModal.tsx index 5e3a23a7d..2643af22d 100644 --- a/src/plugins/serverInfo/GuildInfoModal.tsx +++ b/src/plugins/serverInfo/GuildInfoModal.tsx @@ -16,7 +16,7 @@ import { findComponentByCodeLazy, findCssClassesLazy } from "@webpack"; import { FluxDispatcher, Forms, GuildChannelStore, GuildMemberStore, GuildRoleStore, IconUtils, Parser, PresenceStore, RelationshipStore, ScrollerThin, SnowflakeUtils, TabBar, Timestamp, useEffect, UserStore, UserUtils, useState, useStateFromStores } from "@webpack/common"; const IconClasses = findCssClassesLazy("icon", "acronym", "childWrapper"); -const FriendRow = findComponentByCodeLazy("discriminatorClass:", ".isMobileOnline", "getAvatarURL"); +const FriendRow = findComponentByCodeLazy("discriminatorClass:", ".isMobileOnline", "avatarSrc:"); const cl = classNameFactory("vc-gp-"); diff --git a/src/webpack/common/utils.ts b/src/webpack/common/utils.ts index e740a4079..ee39dcb69 100644 --- a/src/webpack/common/utils.ts +++ b/src/webpack/common/utils.ts @@ -79,6 +79,7 @@ const ToastType = { BOOKMARK: "bookmark", CLOCK: "clock" }; + const ToastPosition = { TOP: 0, BOTTOM: 1 @@ -103,28 +104,35 @@ export interface ToastOptions { duration?: number; } +interface ToastsExports { + showToast: (data: ToastData) => void; + popToast(): void; +} + +const ToastsExports = mapMangledModuleLazy(".currentToastMap.has(", { + showToast: filters.byCode(".currentToastMap.has("), + popToast: filters.byCode(".delete(") +}); + +export function createToast(message: string, type: string, options?: ToastOptions): ToastData { + return { + message, + id: Toasts.genId(), + type, + options + }; +} + export const Toasts = { Type: ToastType, Position: ToastPosition, - // what's less likely than getting 0 from Math.random()? Getting it twice in a row genId: () => (Math.random() || Math.random()).toString(36).slice(2), - // hack to merge with the following interface, dunno if there's a better way - ...{} as { - show(data: ToastData): void; - pop(): void; - create(message: string, type: string, options?: ToastOptions): ToastData; - } + show: ToastsExports.showToast, + pop: ToastsExports.popToast, + create: createToast, }; -// This is the same module but this is easier -waitFor("showToast", m => { - Toasts.show = m.showToast; - Toasts.pop = m.popToast; - Toasts.create = m.createToast; -}); - - /** * Show a simple toast. If you need more options, use Toasts.show manually */