Skip to content

Commit

Permalink
Merge branch 'Vendicated:main' into toastnotifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ImSkully authored Jan 29, 2025
2 parents d7cf022 + 240195f commit 62f5401
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vencord",
"private": "true",
"version": "1.11.2",
"version": "1.11.3",
"description": "The cutest Discord client mod",
"homepage": "https://github.com/Vendicated/Vencord#readme",
"bugs": {
Expand Down
3 changes: 2 additions & 1 deletion src/components/PluginSettings/PluginModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { Constructor } from "type-fest";
import { PluginMeta } from "~plugins";

import {
ISettingCustomElementProps,
ISettingElementProps,
SettingBooleanComponent,
SettingCustomComponent,
Expand Down Expand Up @@ -74,7 +75,7 @@ function makeDummyUser(user: { username: string; id?: string; avatar?: string; }
return newUser;
}

const Components: Record<OptionType, React.ComponentType<ISettingElementProps<any>>> = {
const Components: Record<OptionType, React.ComponentType<ISettingElementProps<any> | ISettingCustomElementProps<any>>> = {
[OptionType.STRING]: SettingTextComponent,
[OptionType.NUMBER]: SettingNumericComponent,
[OptionType.BIGINT]: SettingNumericComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import { PluginOptionComponent } from "@utils/types";

import { ISettingElementProps } from ".";
import { ISettingCustomElementProps } from ".";

export function SettingCustomComponent({ option, onChange, onError }: ISettingElementProps<PluginOptionComponent>) {
export function SettingCustomComponent({ option, onChange, onError }: ISettingCustomElementProps<PluginOptionComponent>) {
return option.component({ setValue: onChange, setError: onError, option });
}
5 changes: 4 additions & 1 deletion src/components/PluginSettings/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import { DefinedSettings, PluginOptionBase } from "@utils/types";

export interface ISettingElementProps<T extends PluginOptionBase> {
interface ISettingElementPropsBase<T> {
option: T;
onChange(newValue: any): void;
pluginSettings: {
Expand All @@ -30,6 +30,9 @@ export interface ISettingElementProps<T extends PluginOptionBase> {
definedSettings?: DefinedSettings;
}

export type ISettingElementProps<T extends PluginOptionBase> = ISettingElementPropsBase<T>;
export type ISettingCustomElementProps<T extends Omit<PluginOptionBase, "description" | "placeholder">> = ISettingElementPropsBase<T>;

export * from "../../Badge";
export * from "./SettingBooleanComponent";
export * from "./SettingCustomComponent";
Expand Down
5 changes: 1 addition & 4 deletions src/plugins/clientTheme/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,12 @@ function ThemeSettings() {

const settings = definePluginSettings({
color: {
description: "Color your Discord client theme will be based around. Light mode isn't supported",
type: OptionType.COMPONENT,
default: "313338",
component: () => <ThemeSettings />
component: ThemeSettings
},
resetColor: {
description: "Reset Theme Color",
type: OptionType.COMPONENT,
default: "313338",
component: () => (
<Button onClick={() => onPickColor(0x313338)}>
Reset Theme Color
Expand Down
1 change: 0 additions & 1 deletion src/plugins/decor/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import DecorSection from "./ui/components/DecorSection";
export const settings = definePluginSettings({
changeDecoration: {
type: OptionType.COMPONENT,
description: "Change your avatar decoration",
component() {
if (!Vencord.Plugins.plugins.Decor.started) return <Forms.FormText>
Enable Decor and restart your client to change your avatar decoration.
Expand Down
4 changes: 1 addition & 3 deletions src/plugins/ignoreActivities/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ function IdsListComponent(props: { setValue: (value: string) => void; }) {
const settings = definePluginSettings({
importCustomRPC: {
type: OptionType.COMPONENT,
description: "",
component: () => <ImportCustomRPCComponent />
component: ImportCustomRPCComponent
},
listMode: {
type: OptionType.SELECT,
Expand All @@ -168,7 +167,6 @@ const settings = definePluginSettings({
},
idsList: {
type: OptionType.COMPONENT,
description: "",
default: "",
onChange(newValue: string) {
const ids = new Set(newValue.split(",").map(id => id.trim()).filter(Boolean));
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/messageLinkEmbeds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ const settings = definePluginSettings({
},
clearMessageCache: {
type: OptionType.COMPONENT,
description: "Clear the linked message cache",
component: () =>
component: () => (
<Button onClick={() => messageCache.clear()}>
Clear the linked message cache
</Button>
)
}
});

Expand Down
2 changes: 0 additions & 2 deletions src/plugins/reviewDB/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { cl } from "./utils";
export const settings = definePluginSettings({
authorize: {
type: OptionType.COMPONENT,
description: "Authorize with ReviewDB",
component: () => (
<Button onClick={() => authorize()}>
Authorize with ReviewDB
Expand Down Expand Up @@ -56,7 +55,6 @@ export const settings = definePluginSettings({
},
buttons: {
type: OptionType.COMPONENT,
description: "ReviewDB buttons",
component: () => (
<div className={cl("button-grid")} >
<Button onClick={openBlockModal}>Manage Blocked Users</Button>
Expand Down
1 change: 0 additions & 1 deletion src/plugins/textReplace/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const makeEmptyRuleArray = () => [makeEmptyRule()];
const settings = definePluginSettings({
replace: {
type: OptionType.COMPONENT,
description: "",
component: () => {
const { stringRules, regexRules } = settings.use(["stringRules", "regexRules"]);

Expand Down
25 changes: 14 additions & 11 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,16 @@ export type SettingsChecks<D extends SettingsDefinition> = {
(IsDisabled<DefinedSettings<D>> & IsValid<PluginSettingType<D[K]>, DefinedSettings<D>>);
};

export type PluginSettingDef = (PluginSettingCustomDef & Pick<PluginSettingCommon, "onChange">) | ((
| PluginSettingStringDef
| PluginSettingNumberDef
| PluginSettingBooleanDef
| PluginSettingSelectDef
| PluginSettingSliderDef
| PluginSettingComponentDef
| PluginSettingBigIntDef
) & PluginSettingCommon);
export type PluginSettingDef =
(PluginSettingCustomDef & Pick<PluginSettingCommon, "onChange">) |
(PluginSettingComponentDef & Omit<PluginSettingCommon, "description" | "placeholder">) | ((
| PluginSettingStringDef
| PluginSettingNumberDef
| PluginSettingBooleanDef
| PluginSettingSelectDef
| PluginSettingSliderDef
| PluginSettingBigIntDef
) & PluginSettingCommon);

export interface PluginSettingCommon {
description: string;
Expand All @@ -226,12 +227,14 @@ export interface PluginSettingCommon {
*/
target?: "WEB" | "DESKTOP" | "BOTH";
}

interface IsDisabled<D = unknown> {
/**
* Checks if this setting should be disabled
*/
disabled?(this: D): boolean;
}

interface IsValid<T, D = unknown> {
/**
* Prevents the user from saving settings if this is false or a string
Expand Down Expand Up @@ -320,7 +323,7 @@ type PluginSettingType<O extends PluginSettingDef> = O extends PluginSettingStri
O extends PluginSettingBooleanDef ? boolean :
O extends PluginSettingSelectDef ? O["options"][number]["value"] :
O extends PluginSettingSliderDef ? number :
O extends PluginSettingComponentDef ? any :
O extends PluginSettingComponentDef ? O extends { default: infer Default; } ? Default : any :
O extends PluginSettingCustomDef ? O extends { default: infer Default; } ? Default : any :
never;

Expand Down Expand Up @@ -382,7 +385,7 @@ export type PluginOptionNumber = (PluginSettingNumberDef | PluginSettingBigIntDe
export type PluginOptionBoolean = PluginSettingBooleanDef & PluginSettingCommon & IsDisabled & IsValid<boolean>;
export type PluginOptionSelect = PluginSettingSelectDef & PluginSettingCommon & IsDisabled & IsValid<PluginSettingSelectOption>;
export type PluginOptionSlider = PluginSettingSliderDef & PluginSettingCommon & IsDisabled & IsValid<number>;
export type PluginOptionComponent = PluginSettingComponentDef & PluginSettingCommon;
export type PluginOptionComponent = PluginSettingComponentDef & Omit<PluginSettingCommon, "description" | "placeholder">;
export type PluginOptionCustom = PluginSettingCustomDef & Pick<PluginSettingCommon, "onChange">;

export type PluginNative<PluginExports extends Record<string, (event: Electron.IpcMainInvokeEvent, ...args: any[]) => any>> = {
Expand Down

0 comments on commit 62f5401

Please sign in to comment.