aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV <vendicated@riseup.net>2023-09-05 20:10:42 +0200
committerV <vendicated@riseup.net>2023-09-05 20:10:42 +0200
commit8614e176334232fb5288a5b3255d2daa8245061a (patch)
tree3d225b6d9e17b01be7b4cc059b8f45989a2bcea3
parentaecd9d8fda932cc2229a84a45937877b20625758 (diff)
downloadVencord-8614e176334232fb5288a5b3255d2daa8245061a.tar.gz
Vencord-8614e176334232fb5288a5b3255d2daa8245061a.tar.bz2
Vencord-8614e176334232fb5288a5b3255d2daa8245061a.zip
Fix some plugins wrongly displaying the settings cog
-rw-r--r--src/components/PluginSettings/PluginModal.tsx4
-rw-r--r--src/components/PluginSettings/index.tsx4
-rw-r--r--src/utils/misc.tsx10
3 files changed, 14 insertions, 4 deletions
diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx
index f4cab54..f30cede 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 12487c6..f19d326 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={
<button role="switch" onClick={() => openModal()} className={classes(ButtonClasses.button, cl("info-button"))}>
- {plugin.options
+ {plugin.options && !isObjectEmpty(plugin.options)
? <CogWheel />
: <InfoIcon width="24" height="24" />}
</button>
diff --git a/src/utils/misc.tsx b/src/utils/misc.tsx
index ec612a9..2b8ccf8 100644
--- a/src/utils/misc.tsx
+++ b/src/utils/misc.tsx
@@ -75,6 +75,16 @@ export function isObject(obj: unknown): obj is object {
}
/**
+ * 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
*/