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