diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx index f4cab54c..f30cedee 100644 --- a/src/components/PluginSettings/PluginModal.tsx +++ b/src/components/PluginSettings/PluginModal.tsx @@ -23,7 +23,7 @@ import ErrorBoundary from "@components/ErrorBoundary"; import { Flex } from "@components/Flex"; import { proxyLazy } from "@utils/lazy"; import { Margins } from "@utils/margins"; -import { classes } from "@utils/misc"; +import { classes, isObjectEmpty } from "@utils/misc"; import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal"; import { LazyComponent } from "@utils/react"; import { OptionType, Plugin } from "@utils/types"; @@ -89,7 +89,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti const canSubmit = () => Object.values(errors).every(e => !e); - const hasSettings = Boolean(pluginSettings && plugin.options); + const hasSettings = Boolean(pluginSettings && plugin.options && !isObjectEmpty(plugin.options)); React.useEffect(() => { enableStyle(hideBotTagStyle); diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx index 12487c6d..f19d3264 100644 --- a/src/components/PluginSettings/index.tsx +++ b/src/components/PluginSettings/index.tsx @@ -28,7 +28,7 @@ import { SettingsTab } from "@components/VencordSettings/shared"; import { ChangeList } from "@utils/ChangeList"; import { Logger } from "@utils/Logger"; import { Margins } from "@utils/margins"; -import { classes } from "@utils/misc"; +import { classes, isObjectEmpty } from "@utils/misc"; import { openModalLazy } from "@utils/modal"; import { LazyComponent, useAwaiter } from "@utils/react"; import { Plugin } from "@utils/types"; @@ -161,7 +161,7 @@ function PluginCard({ plugin, disabled, onRestartNeeded, onMouseEnter, onMouseLe onMouseLeave={onMouseLeave} infoButton={ diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx index ec612a91..2b8ccf8a 100644 --- a/src/utils/misc.tsx +++ b/src/utils/misc.tsx @@ -74,6 +74,16 @@ export function isObject(obj: unknown): obj is object { return typeof obj === "object" && obj !== null && !Array.isArray(obj); } +/** + * Check if an object is empty or in other words has no own properties + */ +export function isObjectEmpty(obj: object) { + for (const k in obj) + if (Object.hasOwn(obj, k)) return false; + + return true; +} + /** * Returns null if value is not a URL, otherwise return URL object. * Avoids having to wrap url checks in a try/catch