From ac828b2340dba461f2b474d19a233140a7490a86 Mon Sep 17 00:00:00 2001 From: programminglaboratorys <107296738+programminglaboratorys@users.noreply.github.com> Date: Fri, 6 Dec 2024 01:24:27 +0300 Subject: [PATCH] fix: statusPresets finds and patches (#104) * fix: statusPresets finds and patches * fix: statusPresets modal not opening --- src/equicordplugins/statusPresets/index.tsx | 31 ++++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/src/equicordplugins/statusPresets/index.tsx b/src/equicordplugins/statusPresets/index.tsx index 9936f3ba..aac9b577 100644 --- a/src/equicordplugins/statusPresets/index.tsx +++ b/src/equicordplugins/statusPresets/index.tsx @@ -22,11 +22,15 @@ import { definePluginSettings } from "@api/Settings"; import { getUserSettingLazy } from "@api/UserSettings"; import ErrorBoundary from "@components/ErrorBoundary"; import { EquicordDevs } from "@utils/constants"; +import { proxyLazy } from "@utils/lazy"; import { classes } from "@utils/misc"; +import { ModalProps, openModalLazy } from "@utils/modal"; import { useForceUpdater } from "@utils/react"; import definePlugin, { OptionType, StartAt } from "@utils/types"; -import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { extractAndLoadChunksLazy, findByPropsLazy, findComponentByCodeLazy, findModuleId, wreq } from "@webpack"; import { Button, Clickable, Icons, Menu, Toasts, UserStore, useState } from "@webpack/common"; +import { FunctionComponent } from "react"; + const settings = definePluginSettings({ StatusPresets: { @@ -51,11 +55,23 @@ interface DiscordStatus { } const StatusStyles = findByPropsLazy("statusItem"); +// TODO: find clearCustomStatusHint original css/svg or replace const PMenu = findComponentByCodeLazy(".menuItemLabel", ".menuItemInner"); -const EmojiComponent = findComponentByCodeLazy(".translateSurrogatesToInlineEmoji("); +const EmojiComponent = findComponentByCodeLazy(/\.translateSurrogatesToInlineEmoji\(\i.\i\),/); const CustomStatusSettings = getUserSettingLazy("status", "customStatus")!; +const StatsModule: { default: FunctionComponent; } = proxyLazy(() => { + const id = findModuleId("this.renderCustomStatusInput()"); + return wreq(Number(id)); +}); + +const requireCustomStatusModal = extractAndLoadChunksLazy(["action:\"PRESS_ADD_CUSTOM_STATUS\"", ".openModalLazy"]); + +const openCustomStatusModalLazy = () => openModalLazy(async () => { + await requireCustomStatusModal(); + return props => ; +}); function getExpirationMs(expiration: "TODAY" | number) { if (expiration !== "TODAY") return Date.now() + expiration; @@ -140,20 +156,21 @@ export default definePlugin({ { find: "#{intl::STATUS_MENU_LABEL}", replacement: { - match: /!\i\i&&(.{0,20}\i\.Fragment.{0,100}null==(\i).{0,200}customEmojiPlaceholder\}\),onClick:(.*?}))/, - replace: "$self.render($2, $3),false&&$1" + match: /"set-status-submenu-mobile-web".{150,165}void 0\}\)/, + replace: "$&,$self.render()" }, all: true } ], - render(status: null | { emoji: Emoji | null; }, openCustomStatusModal: () => void) { + render() { + const status = CustomStatusSettings.getSetting(); return
{status == null ?
} label="Set Custom Status" renderSubmenu={StatusSubMenuComponent} /> @@ -161,7 +178,7 @@ export default definePlugin({ } icon={() => status.emoji != null ? : null} label="Edit Custom Status" renderSubmenu={StatusSubMenuComponent}