1
0
Fork 1
mirror of https://github.com/Vendicated/Vencord.git synced 2025-01-10 09:56:24 +00:00
This commit is contained in:
Elvy 2025-01-03 18:54:51 +01:00
parent 8197966247
commit abdfea15db
4 changed files with 61 additions and 61 deletions

View file

@ -38,9 +38,9 @@ import { PluginMeta } from "~plugins";
import {
ISettingElementProps,
SettingArrayComponent,
SettingBooleanComponent,
SettingCustomComponent,
SettingListComponent,
SettingNumericComponent,
SettingSelectComponent,
SettingSliderComponent,
@ -83,10 +83,10 @@ const Components: Record<OptionType, React.ComponentType<ISettingElementProps<an
[OptionType.SELECT]: SettingSelectComponent,
[OptionType.SLIDER]: SettingSliderComponent,
[OptionType.COMPONENT]: SettingCustomComponent,
[OptionType.ARRAY]: SettingListComponent,
[OptionType.USERS]: SettingListComponent,
[OptionType.CHANNELS]: SettingListComponent,
[OptionType.GUILDS]: SettingListComponent
[OptionType.ARRAY]: SettingArrayComponent,
[OptionType.USERS]: SettingArrayComponent,
[OptionType.CHANNELS]: SettingArrayComponent,
[OptionType.GUILDS]: SettingArrayComponent
};
export default function PluginModal({ plugin, onRestartNeeded, onClose, transitionState }: PluginModalProps) {

View file

@ -48,7 +48,7 @@ interface UserMentionComponentProps {
guildId: string;
}
export function SettingListComponent({
export function SettingArrayComponent({
option,
pluginSettings,
definedSettings,
@ -107,60 +107,60 @@ export function SettingListComponent({
<ErrorBoundary noop>
<React.Fragment>
{items.map((item, index) => (
<Flex
flexDirection="row"
style={{
gap: "1px",
}}
<Flex
flexDirection="row"
style={{
gap: "1px",
}}
>
{option.type === OptionType.USERS ? (
<UserMentionComponent
userId={item}
className="mention"
/>
) : option.type === OptionType.CHANNELS ? (
<span style={{ color: "white" }}>{wrapChannel(item)}</span>
) : option.type === OptionType.GUILDS ? (
<span style={{ color: "white" }}>
{GuildStore.getGuild(item)?.name || "Unknown Guild"}
</span>
// TODO add logo to guild and channel?
) : (
<span style={{ color: "white" }}>{item}</span>
)}
<Button
size={Button.Sizes.MIN}
onClick={() => removeItem(index)}
style={
{ background: "none", }
}
>
{option.type === OptionType.USERS ? (
<UserMentionComponent
userId={item}
className="mention"
/>
) : option.type === OptionType.CHANNELS ? (
<span style={{ color: "white" }}>{wrapChannel(item)}</span>
) : option.type === OptionType.GUILDS ? (
<span style={{ color: "white" }}>
{GuildStore.getGuild(item)?.name || "Unknown Guild"}
</span>
// TODO add logo to guild and channel?
) : (
<span style={{ color: "white" }}>{item}</span>
)}
<Button
size={Button.Sizes.MIN}
onClick={() => removeItem(index)}
style={
{ background: "none", }
}
>
<CloseIcon/>
</Button>
<CloseIcon />
</Button>
</Flex>
))}
<Flex
flexDirection="row"
style={{
gap: "5px",
marginTop: "10px",
}}
>
{/* Add a single input field */}
<TextInput
type="text"
placeholder="Add Item"
id={`vc-plugin-modal-input-${option.type === OptionType.CHANNELS ? "channel" : option.type === OptionType.GUILDS ? "guild" : option.type === OptionType.USERS ? "user" : "string"}`}
/>
{/* Add a submit button */}
<Button
size={Button.Sizes.MIN}
onClick={handleSubmit}
style={{ background: "none" }}
>
<CheckMarkIcon/>
</Button>
</Flex>
<Flex
flexDirection="row"
style={{
gap: "5px",
marginTop: "10px",
}}
>
{/* Add a single input field */}
<TextInput
type="text"
placeholder="Add Item"
id={`vc-plugin-modal-input-${option.type === OptionType.CHANNELS ? "channel" : option.type === OptionType.GUILDS ? "guild" : option.type === OptionType.USERS ? "user" : "string"}`}
/>
{/* Add a submit button */}
<Button
size={Button.Sizes.MIN}
onClick={handleSubmit}
style={{ background: "none" }}
>
<CheckMarkIcon />
</Button>
</Flex>
</React.Fragment>
</ErrorBoundary>

View file

@ -33,7 +33,7 @@ export interface ISettingElementProps<T extends PluginOptionBase> {
export * from "../../Badge";
export * from "./SettingBooleanComponent";
export * from "./SettingCustomComponent";
export * from "./SettingListComponent";
export * from "./SettingArrayComponent";
export * from "./SettingNumericComponent";
export * from "./SettingSelectComponent";
export * from "./SettingSliderComponent";

View file

@ -10,7 +10,7 @@ import { getIntlMessage } from "@utils/discord";
import definePlugin, { OptionType } from "@utils/types";
import { Menu, React } from "@webpack/common";
function createContextMenu(name: "Guild" | "User" | "Channel", value: any) {
function createContextMenu(name: string, value: any) {
return (
<Menu.MenuItem
id="vc-plugin-settings"
@ -22,7 +22,7 @@ function createContextMenu(name: "Guild" | "User" | "Channel", value: any) {
}
function renderRegisteredPlugins(name: "Guild" | "User" | "Channel", value: any) {
function renderRegisteredPlugins(name: string, value: any) {
const type = name === "Guild" ? OptionType.GUILDS : name === "User" ? OptionType.USERS : OptionType.CHANNELS;
const plugins = registeredPlugins[type];
@ -112,7 +112,7 @@ export default definePlugin({
for (const plugin of Object.values(Vencord.Plugins.plugins)) {
if (!Vencord.Plugins.isPluginEnabled(plugin.name) || !plugin.settings) continue;
const settings = plugin.settings.def;
for (const settingKey of Object.keys(settings)) {
for (const settingKey of Object.keys(settings)) {
const setting = settings[settingKey];
if ((setting.type === OptionType.USERS || setting.type === OptionType.GUILDS || setting.type === OptionType.CHANNELS) && !setting.hidePopout) {
if (!registeredPlugins[setting.type][plugin.name]) {