this repo has no description

settings: Fix custom sections not opening from context menu

and the ability for custom onClick actions

Co-authored-by: NotNite <hi@notnite.com>

Changed files
+8 -3
packages
core-extensions
src
settings
webpackModules
types
src
coreExtensions
+4 -2
packages/core-extensions/src/settings/webpackModules/settings.ts
···
import { SettingsSection, Settings as SettingsType } from "@moonlight-mod/types/coreExtensions/settings";
export const Settings: SettingsType = {
ourSections: [],
sectionNames: [],
sectionMenuItems: {},
-
addSection: (section, label, element, color = null, pos, notice) => {
const data: SettingsSection = {
section,
label,
color,
element,
pos: pos ?? -4,
-
notice: notice
};
Settings.ourSections.push(data);
···
import { SettingsSection, Settings as SettingsType } from "@moonlight-mod/types/coreExtensions/settings";
+
import UserSettingsModalActionCreators from "@moonlight-mod/wp/discord/actions/UserSettingsModalActionCreators";
export const Settings: SettingsType = {
ourSections: [],
sectionNames: [],
sectionMenuItems: {},
+
addSection: (section, label, element, color = null, pos, notice, onClick) => {
const data: SettingsSection = {
section,
label,
color,
element,
pos: pos ?? -4,
+
notice: notice,
+
onClick: onClick ?? (() => UserSettingsModalActionCreators.open(section))
};
Settings.ourSections.push(data);
+4 -1
packages/types/src/coreExtensions/settings.ts
···
element: React.FunctionComponent;
pos: number | ((sections: SettingsSection[]) => number);
notice?: NoticeProps;
_moonlight_submenu?: () => ReactElement | ReactElement[];
};
···
* @param color A color to use for the section
* @param pos The position in the settings menu to place the section
* @param notice A notice to display when in the section
*/
addSection: (
section: string,
···
element: React.FunctionComponent,
color?: string | null,
pos?: number | ((sections: SettingsSection[]) => number),
-
notice?: NoticeProps
) => void;
/**
···
element: React.FunctionComponent;
pos: number | ((sections: SettingsSection[]) => number);
notice?: NoticeProps;
+
onClick?: () => void;
_moonlight_submenu?: () => ReactElement | ReactElement[];
};
···
* @param color A color to use for the section
* @param pos The position in the settings menu to place the section
* @param notice A notice to display when in the section
+
* @param onClick A custom action to execute when clicked from the context menu
*/
addSection: (
section: string,
···
element: React.FunctionComponent,
color?: string | null,
pos?: number | ((sections: SettingsSection[]) => number),
+
notice?: NoticeProps,
+
onClick?: () => void
) => void;
/**