+4
packages/core-extensions/src/settings/webpackModules/settings.ts
+4
packages/core-extensions/src/settings/webpackModules/settings.ts
···
43
43
44
44
_mutateSections: (sections) => {
45
45
for (const section of Settings.ourSections) {
46
+
// Discord's `pos` only supports numbers, so lets call the function to get the position.
47
+
if (typeof section.pos === "function") {
48
+
section.pos = section.pos(sections);
49
+
}
46
50
sections.splice(section.pos < 0 ? sections.length + section.pos : section.pos, 0, section);
47
51
}
48
52
+6
-6
packages/types/src/coreExtensions/settings.ts
+6
-6
packages/types/src/coreExtensions/settings.ts
···
7
7
};
8
8
9
9
export type SettingsSection =
10
-
| { section: "DIVIDER"; pos: number }
11
-
| { section: "HEADER"; label: string; pos: number }
10
+
| { section: "DIVIDER"; pos: number | ((sections: SettingsSection[]) => number) }
11
+
| { section: "HEADER"; label: string; pos: number | ((sections: SettingsSection[]) => number) }
12
12
| {
13
13
section: string;
14
14
label: string;
15
15
color: string | null;
16
16
element: React.FunctionComponent;
17
-
pos: number;
17
+
pos: number | ((sections: SettingsSection[]) => number);
18
18
notice?: NoticeProps;
19
19
_moonlight_submenu?: () => ReactElement | ReactElement[];
20
20
};
···
38
38
label: string,
39
39
element: React.FunctionComponent,
40
40
color?: string | null,
41
-
pos?: number,
41
+
pos?: number | ((section: unknown) => number),
42
42
notice?: NoticeProps
43
43
) => void;
44
44
···
53
53
* Places a divider in the settings menu.
54
54
* @param pos The position in the settings menu to place the divider
55
55
*/
56
-
addDivider: (pos: number | null) => void;
56
+
addDivider: (pos: number | ((section: unknown) => number) | null) => void;
57
57
58
58
/**
59
59
* Places a header in the settings menu.
60
60
* @param pos The position in the settings menu to place the header
61
61
*/
62
-
addHeader: (label: string, pos: number | null) => void;
62
+
addHeader: (label: string, pos: number | ((section: unknown) => number) | null) => void;
63
63
64
64
/**
65
65
* @private