@@ -72,44 +82,32 @@ function ContributorModal({ user }: { user: User; }) {
/>
{user.username}
-
+
{website && (
-
+
+
+
)}
{githubName && (
-
+
+
+
)}
- {plugins.length ? (
-
- This person has {ContributedHyperLink} to {pluralise(plugins.length, "plugin")}!
-
- ) : (
-
- This person has not made any plugins. They likely {ContributedHyperLink} to Vencord in other ways!
-
- )}
-
- {!!plugins.length && (
-
- {plugins.map(p =>
-
showToast("Restart to apply changes!")}
- />
- )}
-
- )}
+
+ {plugins.map(p =>
+
showToast("Restart to apply changes!")}
+ />
+ )}
+
>
);
}
diff --git a/src/components/PluginSettings/LinkIconButton.css b/src/components/PluginSettings/LinkIconButton.css
deleted file mode 100644
index 1055d6c7..00000000
--- a/src/components/PluginSettings/LinkIconButton.css
+++ /dev/null
@@ -1,12 +0,0 @@
-.vc-settings-modal-link-icon {
- height: 32px;
- width: 32px;
- border-radius: 50%;
- border: 4px solid var(--background-tertiary);
- box-sizing: border-box
-}
-
-.vc-settings-modal-links {
- display: flex;
- gap: 0.2em;
-}
diff --git a/src/components/PluginSettings/LinkIconButton.tsx b/src/components/PluginSettings/LinkIconButton.tsx
deleted file mode 100644
index 4dae0e1e..00000000
--- a/src/components/PluginSettings/LinkIconButton.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Vencord, a Discord client mod
- * Copyright (c) 2024 Vendicated and contributors
- * SPDX-License-Identifier: GPL-3.0-or-later
- */
-
-import "./LinkIconButton.css";
-
-import { getTheme, Theme } from "@utils/discord";
-import { MaskedLink, Tooltip } from "@webpack/common";
-
-import { GithubIcon, WebsiteIcon } from "..";
-
-export function GithubLinkIcon() {
- const theme = getTheme() === Theme.Light ? "#000000" : "#FFFFFF";
- return
;
-}
-
-export function WebsiteLinkIcon() {
- const theme = getTheme() === Theme.Light ? "#000000" : "#FFFFFF";
- return
;
-}
-
-interface Props {
- text: string;
- href: string;
-}
-
-function LinkIcon({ text, href, Icon }: Props & { Icon: React.ComponentType; }) {
- return (
-
- {props => (
-
-
-
- )}
-
- );
-}
-
-export const WebsiteButton = (props: Props) =>
;
-export const GithubButton = (props: Props) =>
;
diff --git a/src/components/PluginSettings/PluginModal.css b/src/components/PluginSettings/PluginModal.css
deleted file mode 100644
index 1f4b9aaa..00000000
--- a/src/components/PluginSettings/PluginModal.css
+++ /dev/null
@@ -1,7 +0,0 @@
-.vc-plugin-modal-info {
- align-items: center;
-}
-
-.vc-plugin-modal-description {
- flex-grow: 1;
-}
diff --git a/src/components/PluginSettings/PluginModal.tsx b/src/components/PluginSettings/PluginModal.tsx
index 7baeba08..78f3c9db 100644
--- a/src/components/PluginSettings/PluginModal.tsx
+++ b/src/components/PluginSettings/PluginModal.tsx
@@ -16,28 +16,22 @@
* along with this program. If not, see
.
*/
-import "./PluginModal.css";
-
import { generateId } from "@api/Commands";
import { useSettings } from "@api/Settings";
-import { classNameFactory } from "@api/Styles";
import ErrorBoundary from "@components/ErrorBoundary";
import { Flex } from "@components/Flex";
-import { gitRemote } from "@shared/vencordUserAgent";
import { proxyLazy } from "@utils/lazy";
import { Margins } from "@utils/margins";
import { classes, isObjectEmpty } from "@utils/misc";
-import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize, openModal } from "@utils/modal";
+import { ModalCloseButton, ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot, ModalSize } from "@utils/modal";
+import { LazyComponent } from "@utils/react";
import { OptionType, Plugin } from "@utils/types";
-import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
+import { findByCode, findByPropsLazy } from "@webpack";
import { Button, Clickable, FluxDispatcher, Forms, React, Text, Tooltip, UserStore, UserUtils } from "@webpack/common";
import { User } from "discord-types/general";
import { Constructor } from "type-fest";
-import { PluginMeta } from "~plugins";
-
import {
- ISettingCustomElementProps,
ISettingElementProps,
SettingBooleanComponent,
SettingCustomComponent,
@@ -47,11 +41,8 @@ import {
SettingTextComponent
} from "./components";
import { openContributorModal } from "./ContributorModal";
-import { GithubButton, WebsiteButton } from "./LinkIconButton";
-const cl = classNameFactory("vc-plugin-modal-");
-
-const UserSummaryItem = findComponentByCodeLazy("defaultRenderUser", "showDefaultAvatarsForNullUsers");
+const UserSummaryItem = LazyComponent(() => findByCode("defaultRenderUser", "showDefaultAvatarsForNullUsers"));
const AvatarStyles = findByPropsLazy("moreUsers", "emptyUser", "avatarContainer", "clickableAvatar");
const UserRecord: Constructor
> = proxyLazy(() => UserStore.getCurrentUser().constructor) as any;
@@ -75,15 +66,14 @@ function makeDummyUser(user: { username: string; id?: string; avatar?: string; }
return newUser;
}
-const Components: Record | ISettingCustomElementProps>> = {
+const Components: Record>> = {
[OptionType.STRING]: SettingTextComponent,
[OptionType.NUMBER]: SettingNumericComponent,
[OptionType.BIGINT]: SettingNumericComponent,
[OptionType.BOOLEAN]: SettingBooleanComponent,
[OptionType.SELECT]: SettingSelectComponent,
[OptionType.SLIDER]: SettingSliderComponent,
- [OptionType.COMPONENT]: SettingCustomComponent,
- [OptionType.CUSTOM]: () => null,
+ [OptionType.COMPONENT]: SettingCustomComponent
};
export default function PluginModal({ plugin, onRestartNeeded, onClose, transitionState }: PluginModalProps) {
@@ -104,14 +94,14 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
(async () => {
for (const user of plugin.authors.slice(0, 6)) {
const author = user.id
- ? await UserUtils.getUser(`${user.id}`)
+ ? await UserUtils.fetchUser(`${user.id}`)
.catch(() => makeDummyUser({ username: user.name }))
: makeDummyUser({ username: user.name });
setAuthors(a => [...a, author]);
}
})();
- }, [plugin.authors]);
+ }, []);
async function saveAndClose() {
if (!plugin.options) {
@@ -131,8 +121,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
for (const [key, value] of Object.entries(tempSettings)) {
const option = plugin.options[key];
pluginSettings[key] = value;
-
- if (option.type === OptionType.CUSTOM) continue;
+ option?.onChange?.(value);
if (option?.restartNeeded) restartNeeded = true;
}
if (restartNeeded) onRestartNeeded();
@@ -144,7 +133,7 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
return There are no settings for this plugin.;
} else {
const options = Object.entries(plugin.options).map(([key, setting]) => {
- if (setting.type === OptionType.CUSTOM || setting.hidden) return null;
+ if (setting.hidden) return null;
function onChange(newValue: any) {
setTempSettings(s => ({ ...s, [key]: newValue }));
@@ -192,54 +181,16 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
);
}
- /*
- function switchToPopout() {
- onClose();
-
- const PopoutKey = `DISCORD_VENCORD_PLUGIN_SETTINGS_MODAL_${plugin.name}`;
- PopoutActions.open(
- PopoutKey,
- () => PopoutActions.close(PopoutKey)}
- />
- );
- }
- */
-
- const pluginMeta = PluginMeta[plugin.name];
-
return (
{plugin.name}
-
- {/*
-
- */}
-
- {plugin.description}
- {!pluginMeta.userPlugin && (
-
-
-
-
- )}
-
+ About {plugin.name}
+ {plugin.description}
Authors
Cancel
@@ -313,13 +264,3 @@ export default function PluginModal({ plugin, onRestartNeeded, onClose, transiti
);
}
-
-export function openPluginModal(plugin: Plugin, onRestartNeeded?: (pluginName: string) => void) {
- openModal(modalProps => (
- onRestartNeeded?.(plugin.name)}
- />
- ));
-}
diff --git a/src/components/PluginSettings/components/SettingCustomComponent.tsx b/src/components/PluginSettings/components/SettingCustomComponent.tsx
index 25e8c9c6..af7192f3 100644
--- a/src/components/PluginSettings/components/SettingCustomComponent.tsx
+++ b/src/components/PluginSettings/components/SettingCustomComponent.tsx
@@ -18,8 +18,8 @@
import { PluginOptionComponent } from "@utils/types";
-import { ISettingCustomElementProps } from ".";
+import { ISettingElementProps } from ".";
-export function SettingCustomComponent({ option, onChange, onError }: ISettingCustomElementProps) {
+export function SettingCustomComponent({ option, onChange, onError }: ISettingElementProps) {
return option.component({ setValue: onChange, setError: onError, option });
}
diff --git a/src/components/PluginSettings/components/SettingNumericComponent.tsx b/src/components/PluginSettings/components/SettingNumericComponent.tsx
index b724717d..446d2504 100644
--- a/src/components/PluginSettings/components/SettingNumericComponent.tsx
+++ b/src/components/PluginSettings/components/SettingNumericComponent.tsx
@@ -16,8 +16,6 @@
* along with this program. If not, see .
*/
-import { Margins } from "@utils/margins";
-import { wordsFromCamel, wordsToTitle } from "@utils/text";
import { OptionType, PluginOptionNumber } from "@utils/types";
import { Forms, React, TextInput } from "@webpack/common";
@@ -56,8 +54,7 @@ export function SettingNumericComponent({ option, pluginSettings, definedSetting
return (
- {wordsToTitle(wordsFromCamel(id))}
- {option.description}
+ {option.description}
.
*/
-import { Margins } from "@utils/margins";
-import { wordsFromCamel, wordsToTitle } from "@utils/text";
import { PluginOptionSelect } from "@utils/types";
import { Forms, React, Select } from "@webpack/common";
@@ -46,8 +44,7 @@ export function SettingSelectComponent({ option, pluginSettings, definedSettings
return (
- {wordsToTitle(wordsFromCamel(id))}
- {option.description}
+ {option.description}
.
*/
-import { Margins } from "@utils/margins";
-import { wordsFromCamel, wordsToTitle } from "@utils/text";
import { PluginOptionSlider } from "@utils/types";
import { Forms, React, Slider } from "@webpack/common";
@@ -52,8 +50,7 @@ export function SettingSliderComponent({ option, pluginSettings, definedSettings
return (
- {wordsToTitle(wordsFromCamel(id))}
- {option.description}
+ {option.description}
.
*/
-import { Margins } from "@utils/margins";
-import { wordsFromCamel, wordsToTitle } from "@utils/text";
import { PluginOptionString } from "@utils/types";
import { Forms, React, TextInput } from "@webpack/common";
@@ -43,8 +41,7 @@ export function SettingTextComponent({ option, pluginSettings, definedSettings,
return (
- {wordsToTitle(wordsFromCamel(id))}
- {option.description}
+ {option.description}
{
+export interface ISettingElementProps {
option: T;
onChange(newValue: any): void;
pluginSettings: {
@@ -30,9 +30,6 @@ interface ISettingElementPropsBase {
definedSettings?: DefinedSettings;
}
-export type ISettingElementProps = ISettingElementPropsBase;
-export type ISettingCustomElementProps> = ISettingElementPropsBase;
-
export * from "../../Badge";
export * from "./SettingBooleanComponent";
export * from "./SettingCustomComponent";
diff --git a/src/components/PluginSettings/contributorModal.css b/src/components/PluginSettings/contributorModal.css
index 3a698e2c..a8af8c8b 100644
--- a/src/components/PluginSettings/contributorModal.css
+++ b/src/components/PluginSettings/contributorModal.css
@@ -17,7 +17,6 @@
font-size: 20px;
height: 20px;
position: relative;
- text-wrap: nowrap;
}
.vc-author-modal-name::before {
@@ -25,13 +24,11 @@
display: block;
position: absolute;
height: 100%;
- width: 32px;
+ width: 16px;
background: var(--background-tertiary);
z-index: -1;
- left: -32px;
+ left: -16px;
top: 0;
- border-top-left-radius: 9999px;
- border-bottom-left-radius: 9999px;
}
.vc-author-modal-avatar {
@@ -42,10 +39,19 @@
.vc-author-modal-links {
margin-left: auto;
+ display: flex;
+ gap: 0.2em;
+}
+
+.vc-author-modal-links img {
+ height: 32px;
+ width: 32px;
+ border-radius: 50%;
+ border: 4px solid var(--background-tertiary);
+ box-sizing: border-box
}
.vc-author-modal-plugins {
display: grid;
gap: 0.5em;
- margin-top: 0.75em;
}
diff --git a/src/components/PluginSettings/index.tsx b/src/components/PluginSettings/index.tsx
index 959a4d01..3712f3de 100644
--- a/src/components/PluginSettings/index.tsx
+++ b/src/components/PluginSettings/index.tsx
@@ -22,32 +22,32 @@ import * as DataStore from "@api/DataStore";
import { showNotice } from "@api/Notices";
import { Settings, useSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
-import { CogWheel, InfoIcon } from "@components/Icons";
-import { openPluginModal } from "@components/PluginSettings/PluginModal";
+import PluginModal from "@components/PluginSettings/PluginModal";
import { AddonCard } from "@components/VencordSettings/AddonCard";
import { SettingsTab } from "@components/VencordSettings/shared";
import { ChangeList } from "@utils/ChangeList";
-import { proxyLazy } from "@utils/lazy";
import { Logger } from "@utils/Logger";
import { Margins } from "@utils/margins";
import { classes, isObjectEmpty } from "@utils/misc";
-import { useAwaiter } from "@utils/react";
+import { openModalLazy } from "@utils/modal";
+import { LazyComponent, useAwaiter } from "@utils/react";
import { Plugin } from "@utils/types";
-import { findByPropsLazy } from "@webpack";
-import { Alerts, Button, Card, Forms, lodash, Parser, React, Select, Text, TextInput, Toasts, Tooltip, useMemo } from "@webpack/common";
-import { JSX } from "react";
+import { findByCode, findByPropsLazy } from "@webpack";
+import { Alerts, Button, Card, Forms, Parser, React, Select, Text, TextInput, Toasts, Tooltip } from "@webpack/common";
-import Plugins, { ExcludedPlugins } from "~plugins";
+import Plugins from "~plugins";
+
+import { startDependenciesRecursive, startPlugin, stopPlugin } from "../../plugins";
-// Avoid circular dependency
-const { startDependenciesRecursive, startPlugin, stopPlugin } = proxyLazy(() => require("../../plugins"));
const cl = classNameFactory("vc-plugins-");
const logger = new Logger("PluginSettings", "#a6d189");
-const InputStyles = findByPropsLazy("inputWrapper", "inputDefault", "error");
+const InputStyles = findByPropsLazy("inputDefault", "inputWrapper");
const ButtonClasses = findByPropsLazy("button", "disabled", "enabled");
+const CogWheel = LazyComponent(() => findByCode("18.564C15.797 19.099 14.932 19.498 14 19.738V22H10V19.738C9.069"));
+const InfoIcon = LazyComponent(() => findByCode("4.4408921e-16 C4.4771525,-1.77635684e-15 4.4408921e-16"));
function showErrorToast(message: string) {
Toasts.show({
@@ -69,7 +69,7 @@ function ReloadRequiredCard({ required }: { required: boolean; }) {
Restart now to apply new plugins and their settings
-