1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 18:06:22 +00:00

using findbyCodeLazy for setStatus

This commit is contained in:
programminglaboratorys 2024-09-30 01:52:39 +03:00
parent adc0d2f0d7
commit 4ccf12f5b4

View file

@ -21,7 +21,7 @@ import { getUserSettingLazy } from "@api/UserSettings";
import ErrorBoundary from "@components/ErrorBoundary"; import ErrorBoundary from "@components/ErrorBoundary";
import { Devs } from "@utils/constants"; import { Devs } from "@utils/constants";
import definePlugin, { OptionType, StartAt } from "@utils/types"; import definePlugin, { OptionType, StartAt } from "@utils/types";
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; import { findByCodeLazy, findByPropsLazy, findComponentByCodeLazy } from "@webpack";
import { Button, Clickable, Icons, Menu, Toasts, useState } from "@webpack/common"; import { Button, Clickable, Icons, Menu, Toasts, useState } from "@webpack/common";
// const { PMenu } = mapMangledModuleLazy("{id:t,label:n,icon:c,hint:_,renderSubmenu:E,...h}", { // const { PMenu } = mapMangledModuleLazy("{id:t,label:n,icon:c,hint:_,renderSubmenu:E,...h}", {
@ -39,7 +39,8 @@ const StatusStyles = findByPropsLazy("statusItem");
const statusSettings = getUserSettingLazy("status", "status"); const statusSettings = getUserSettingLazy("status", "status");
const customStatusSettings = getUserSettingLazy("status", "customStatus"); const customStatusSettings = getUserSettingLazy("status", "customStatus");
const setStatusFunc = findByCodeLazy(/default\.track\(\i.\i.CUSTOM_STATUS_UPDATED/);
const setStatus = (status: DiscordStatus) => setStatusFunc(status.text, status.emojiInfo, status.clearAfter, { "location": { "section": "Account Panel", "object": "Avatar" } });
interface Emoji { interface Emoji {
animated: boolean; animated: boolean;
@ -64,9 +65,6 @@ const settings = definePluginSettings({
}); });
function SetStatus(status: DiscordStatus, sourceAnalyticsContext: any) {
return Vencord.Webpack.wreq(720449).Z(status.text, status.emojiInfo, status.clearAfter, sourceAnalyticsContext);
}
const RenderStatusMenuItem = ({ status }) => { const RenderStatusMenuItem = ({ status }) => {
@ -111,7 +109,7 @@ const StatusSubMenuComponent = () => {
{Object.values((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(status => <Menu.MenuItem {Object.values((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(status => <Menu.MenuItem
id={"status-presets-" + status.text} id={"status-presets-" + status.text}
label={status.status} label={status.status}
action={() => SetStatus(status, { "location": { "section": "Account Panel", "object": "Avatar" } })} action={() => setStatus(status)}
render={() => <RenderStatusMenuItem status={status} />} render={() => <RenderStatusMenuItem status={status} />}
/>)} />)}
</Menu.Menu>; </Menu.Menu>;
@ -154,7 +152,7 @@ export default definePlugin({
id="sp-edit/presets-status" id="sp-edit/presets-status"
action="PRESS_EDIT_CUSTOM_STATUS" action="PRESS_EDIT_CUSTOM_STATUS"
onClick={openModal} onClick={openModal}
hint={<Clickable tabIndex={-1} className={StatusStyles.clearCustomStatusHint} onClick={() => customStatusSettings.updateSetting(null)}><Icons.CircleXIcon size="sm" /></Clickable>} hint={<Clickable className={StatusStyles.clearCustomStatusHint} onClick={() => customStatusSettings.updateSetting(null)}><Icons.CircleXIcon size="sm" /></Clickable>}
icon={() => status.emoji != null ? <EmojiComponent emoji={status.emoji} animate={false} hideTooltip={false} /> : null} icon={() => status.emoji != null ? <EmojiComponent emoji={status.emoji} animate={false} hideTooltip={false} /> : null}
label="Edit Custom Status" renderSubmenu={StatusSubMenuComponent} />} label="Edit Custom Status" renderSubmenu={StatusSubMenuComponent} />}
</ErrorBoundary>; </ErrorBoundary>;