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