Merge pull request #210 from MeguminSama/feat/computedSettingsPositions
Cynthia Foxwell 4 weeks ago 2 files (+10, -6)
@@ -43,6 +43,10 @@ },_mutateSections: (sections) => {for (const section of Settings.ourSections) {+ // Discord's `pos` only supports numbers, so lets call the function to get the position.+ if (typeof section.pos === "function") {+ section.pos = section.pos(sections);+ }sections.splice(section.pos < 0 ? sections.length + section.pos : section.pos, 0, section);}
@@ -7,14 +7,14 @@ element: React.FunctionComponent;};export type SettingsSection =- | { section: "DIVIDER"; pos: number }- | { section: "HEADER"; label: string; pos: number }+ | { section: "DIVIDER"; pos: number | ((sections: SettingsSection[]) => number) }+ | { section: "HEADER"; label: string; pos: number | ((sections: SettingsSection[]) => number) }| {section: string;label: string;color: string | null;element: React.FunctionComponent;- pos: number;+ pos: number | ((sections: SettingsSection[]) => number);notice?: NoticeProps;_moonlight_submenu?: () => ReactElement | ReactElement[];};@@ -38,7 +38,7 @@ section: string,label: string,element: React.FunctionComponent,color?: string | null,- pos?: number,+ pos?: number | ((sections: SettingsSection[]) => number),notice?: NoticeProps) => void;@@ -53,13 +53,13 @@ /*** Places a divider in the settings menu.* @param pos The position in the settings menu to place the divider*/- addDivider: (pos: number | null) => void;+ addDivider: (pos: number | ((sections: SettingsSection[]) => number) | null) => void;/*** Places a header in the settings menu.* @param pos The position in the settings menu to place the header*/- addHeader: (label: string, pos: number | null) => void;+ addHeader: (label: string, pos: number | ((sections: SettingsSection[]) => number) | null) => void;/*** @private