From 69b53f1fa404e21721a6a29f422f5976b96df607 Mon Sep 17 00:00:00 2001 From: programminglaboratorys Date: Fri, 27 Sep 2024 17:33:05 +0300 Subject: [PATCH] fixes and made use of UserSettingApi --- src/plugins/statusPresets/index.tsx | 83 ++++++++++++++++++++++++----- 1 file changed, 70 insertions(+), 13 deletions(-) diff --git a/src/plugins/statusPresets/index.tsx b/src/plugins/statusPresets/index.tsx index e2b769e67..8cae9064c 100644 --- a/src/plugins/statusPresets/index.tsx +++ b/src/plugins/statusPresets/index.tsx @@ -18,13 +18,29 @@ import { NavContextMenuPatchCallback } from "@api/ContextMenu"; import { definePluginSettings } from "@api/Settings"; +import { getUserSettingLazy } from "@api/UserSettings"; +import ErrorBoundary from "@components/ErrorBoundary"; import { Devs } from "@utils/constants"; import definePlugin, { OptionType } from "@utils/types"; -import { findByPropsLazy } from "@webpack"; -import { Button, Menu, Text, Toasts, useState } from "@webpack/common"; +import { findByPropsLazy, findComponentByCodeLazy } from "@webpack"; +import { Button, Clickable, Menu, Text, Toasts, useState } from "@webpack/common"; + +// const { PMenu } = mapMangledModuleLazy("{id:t,label:n,icon:c,hint:_,renderSubmenu:E,...h}", { +// PMenu: filters.byCode("{id:t,label:n,icon:c,hint:_,renderSubmenu:E,...h}") +// }); + +const PMenu = findComponentByCodeLazy("{id:t,label:n,icon:c,hint:_,renderSubmenu:h,...E}"); +const EmojiComponent = findComponentByCodeLazy("let{emoji:t,className:n,animate:r=!0,hideTooltip:a,tooltipDelay:o}"); +const PSubMenu = findComponentByCodeLazy("submenuPaddingContainer,children:(0,i.jsx)(o.Menu,{contextMenuApiArguments:"); +// +// submenuPaddingContainer,children:( const Components = findByPropsLazy("Status"); const StatusStyles = findByPropsLazy("statusItem"); +const Icons = findByPropsLazy("CircleXIcon"); +const statusSettings = getUserSettingLazy("status", "status"); +const customStatusSettings = getUserSettingLazy("status", "status"); + interface Emoji { animated: boolean; @@ -64,12 +80,7 @@ const RenderStatusMenuItem = ({ status }) => { return
- {isHovering ? { delete settings.store.StatusPresets[status.text]; Toasts.show({ @@ -77,10 +88,15 @@ const RenderStatusMenuItem = ({ status }) => { type: Toasts.Type.SUCCESS, id: Toasts.genId() }); - }} - /> : : }
{status.status}
{status.text}
@@ -89,7 +105,6 @@ const RenderStatusMenuItem = ({ status }) => { function MakeContextCallback(): NavContextMenuPatchCallback { return (children, _) => { - console.log("BLAH. presets", children); children[0]?.props.children.splice(1, 0, +
+ {status == null ? { OnClose(), openStatusModal(); }} + icon={() =>
} + label="Set Custom Status" renderSubmenu={() => { + return { }}> + {Object.values((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(status => console.log("pog")} + render={() => } + />)} + ; + }} /> : { OnClose(), openStatusModal(); }} + hint={ customStatusSettings.updateSetting(null)}>} + icon={() => status.emoji != null ? : null} + label="Edit Custom Status" renderSubmenu={() => { + return { }}> + {Object.values((settings.store.StatusPresets as { [k: string]: DiscordStatus; })).map(status => console.log("pog")} + render={() => } + />)} + ; + }} />} + ; + }, renderRememberButton(statue: DiscordStatus) { return