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
··· 1 1 import { SettingsSection, Settings as SettingsType } from "@moonlight-mod/types/coreExtensions/settings"; 2 + import UserSettingsModalActionCreators from "@moonlight-mod/wp/discord/actions/UserSettingsModalActionCreators"; 2 3 3 4 export const Settings: SettingsType = { 4 5 ourSections: [], 5 6 sectionNames: [], 6 7 sectionMenuItems: {}, 7 8 8 - addSection: (section, label, element, color = null, pos, notice) => { 9 + addSection: (section, label, element, color = null, pos, notice, onClick) => { 9 10 const data: SettingsSection = { 10 11 section, 11 12 label, 12 13 color, 13 14 element, 14 15 pos: pos ?? -4, 15 - notice: notice 16 + notice: notice, 17 + onClick: onClick ?? (() => UserSettingsModalActionCreators.open(section)) 16 18 }; 17 19 18 20 Settings.ourSections.push(data);
+4 -1
packages/types/src/coreExtensions/settings.ts
··· 16 16 element: React.FunctionComponent; 17 17 pos: number | ((sections: SettingsSection[]) => number); 18 18 notice?: NoticeProps; 19 + onClick?: () => void; 19 20 _moonlight_submenu?: () => ReactElement | ReactElement[]; 20 21 }; 21 22 ··· 32 33 * @param color A color to use for the section 33 34 * @param pos The position in the settings menu to place the section 34 35 * @param notice A notice to display when in the section 36 + * @param onClick A custom action to execute when clicked from the context menu 35 37 */ 36 38 addSection: ( 37 39 section: string, ··· 39 41 element: React.FunctionComponent, 40 42 color?: string | null, 41 43 pos?: number | ((sections: SettingsSection[]) => number), 42 - notice?: NoticeProps 44 + notice?: NoticeProps, 45 + onClick?: () => void 43 46 ) => void; 44 47 45 48 /**