Skip to content

Commit 0076200

Browse files
authored
fix(settings): add support for discord 306.4+ (#208)
1 parent 1679f97 commit 0076200

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/lib/ui/settings/patches/tabs.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { after } from "@lib/api/patcher";
2-
import { findInReactTree } from "@lib/utils";
32
import { TableRow } from "@metro/common/components";
43
import { findByNameLazy, findByPropsLazy } from "@metro/wrappers";
54
import { registeredSections } from "@ui/settings";
65

76
import { CustomPageRenderer, wrapOnPress } from "./shared";
8-
import { Strings } from "@core/i18n";
9-
import { TableRowIcon } from "@metro/common/components";
7+
import { findInReactTree } from "@lib/utils";
108

119
const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG");
10+
const createListModule = findByPropsLazy("createList");
1211
const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false);
1312

1413
function useIsFirstRender() {
@@ -72,6 +71,29 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
7271
});
7372
});
7473

74+
try{
75+
unpatches.push(after("createList", createListModule, function(args, ret) {
76+
const [config] = args;
77+
78+
if (config?.sections && Array.isArray(config.sections)) {
79+
const sections = config.sections;
80+
// Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816
81+
let index = -~sections.findIndex((i: any) => i.settings?.includes("ACCOUNT")) || 1;
82+
83+
Object.keys(registeredSections).forEach(sect => {
84+
const alreadyExists = sections.some((s: any) => s.label === sect);
85+
if (!alreadyExists) {
86+
sections.splice(index++, 0, {
87+
label: sect,
88+
title: sect,
89+
settings: registeredSections[sect].map(a => a.key)
90+
});
91+
}
92+
});
93+
}
94+
return ret;
95+
},));
96+
}catch{
7597
unpatches.push(after("default", SettingsOverviewScreen, (_, ret) => {
7698
if (useIsFirstRender()) return; // :shrug:
7799

@@ -87,4 +109,5 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
87109
});
88110
});
89111
}));
90-
}
112+
}
113+
};

0 commit comments

Comments
 (0)