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 { import {
ISettingElementProps, ISettingElementProps,
SettingArrayComponent,
SettingBooleanComponent, SettingBooleanComponent,
SettingCustomComponent, SettingCustomComponent,
SettingListComponent,
SettingNumericComponent, SettingNumericComponent,
SettingSelectComponent, SettingSelectComponent,
SettingSliderComponent, SettingSliderComponent,
@ -83,10 +83,10 @@ const Components: Record<OptionType, React.ComponentType<ISettingElementProps<an
[OptionType.SELECT]: SettingSelectComponent, [OptionType.SELECT]: SettingSelectComponent,
[OptionType.SLIDER]: SettingSliderComponent, [OptionType.SLIDER]: SettingSliderComponent,
[OptionType.COMPONENT]: SettingCustomComponent, [OptionType.COMPONENT]: SettingCustomComponent,
[OptionType.ARRAY]: SettingListComponent, [OptionType.ARRAY]: SettingArrayComponent,
[OptionType.USERS]: SettingListComponent, [OptionType.USERS]: SettingArrayComponent,
[OptionType.CHANNELS]: SettingListComponent, [OptionType.CHANNELS]: SettingArrayComponent,
[OptionType.GUILDS]: SettingListComponent [OptionType.GUILDS]: SettingArrayComponent
}; };
export default function PluginModal({ plugin, onRestartNeeded, onClose, transitionState }: PluginModalProps) { export default function PluginModal({ plugin, onRestartNeeded, onClose, transitionState }: PluginModalProps) {

View file

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

View file

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

View file

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