Merge branch 'dev' into github
This commit is contained in:
commit
8833a41004
2 changed files with 39 additions and 22 deletions
|
|
@ -13,6 +13,7 @@ import { injectFluxInterceptor } from "@lib/api/flux";
|
||||||
import { patchJsx } from "@lib/api/react/jsx";
|
import { patchJsx } from "@lib/api/react/jsx";
|
||||||
import { logger } from "@lib/utils/logger";
|
import { logger } from "@lib/utils/logger";
|
||||||
import { patchSettings } from "@ui/settings";
|
import { patchSettings } from "@ui/settings";
|
||||||
|
import { getDebugInfo } from "@lib/api/debug";
|
||||||
|
|
||||||
import * as lib from "./lib";
|
import * as lib from "./lib";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,13 @@
|
||||||
import { after } from "@lib/api/patcher";
|
import { after } from "@lib/api/patcher";
|
||||||
import { findInReactTree } from "@lib/utils";
|
|
||||||
import { TableRow } from "@metro/common/components";
|
import { TableRow } from "@metro/common/components";
|
||||||
import { findByNameLazy, findByPropsLazy } from "@metro/wrappers";
|
import { findByNameLazy, findByPropsLazy } from "@metro/wrappers";
|
||||||
import { registeredSections } from "@ui/settings";
|
import { registeredSections } from "@ui/settings";
|
||||||
|
|
||||||
import { CustomPageRenderer, wrapOnPress } from "./shared";
|
import { CustomPageRenderer, wrapOnPress } from "./shared";
|
||||||
import { Strings } from "@core/i18n";
|
import { findInReactTree } from "@lib/utils";
|
||||||
import { TableRowIcon } from "@metro/common/components";
|
|
||||||
|
|
||||||
const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG");
|
const settingConstants = findByPropsLazy("SETTING_RENDERER_CONFIG");
|
||||||
|
const createListModule = findByPropsLazy("createList");
|
||||||
const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false);
|
const SettingsOverviewScreen = findByNameLazy("SettingsOverviewScreen", false);
|
||||||
|
|
||||||
function useIsFirstRender() {
|
function useIsFirstRender() {
|
||||||
|
|
@ -80,26 +79,43 @@ export function patchTabsUI(unpatches: (() => void | boolean)[]) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const createListModule = findByPropsLazy("createList");
|
try{
|
||||||
|
unpatches.push(after("createList", createListModule, function(args, ret) {
|
||||||
unpatches.push(after("createList", createListModule, function(args, ret) {
|
const [config] = args;
|
||||||
const [config] = args;
|
|
||||||
|
|
||||||
if (config?.sections && Array.isArray(config.sections)) {
|
|
||||||
const sections = config.sections;
|
|
||||||
let index = -~sections.findIndex((i: any) => i.settings?.includes("ACCOUNT")) || 1;
|
|
||||||
|
|
||||||
|
if (config?.sections && Array.isArray(config.sections)) {
|
||||||
|
const sections = config.sections;
|
||||||
|
// Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816
|
||||||
|
let index = -~sections.findIndex((i: any) => i.settings?.includes("ACCOUNT")) || 1;
|
||||||
|
|
||||||
|
Object.keys(registeredSections).forEach(sect => {
|
||||||
|
const alreadyExists = sections.some((s: any) => s.label === sect);
|
||||||
|
if (!alreadyExists) {
|
||||||
|
sections.splice(index++, 0, {
|
||||||
|
label: sect,
|
||||||
|
title: sect,
|
||||||
|
settings: registeredSections[sect].map(a => a.key)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},));
|
||||||
|
}catch{
|
||||||
|
unpatches.push(after("default", SettingsOverviewScreen, (_, ret) => {
|
||||||
|
if (useIsFirstRender()) return; // :shrug:
|
||||||
|
|
||||||
|
const { sections } = findInReactTree(ret, i => i.props?.sections).props;
|
||||||
|
// Credit to @palmdevs - https://discord.com/channels/1196075698301968455/1243605828783571024/1307940348378742816
|
||||||
|
let index = -~sections.findIndex((i: any) => i.settings.includes("ACCOUNT")) || 1;
|
||||||
|
|
||||||
Object.keys(registeredSections).forEach(sect => {
|
Object.keys(registeredSections).forEach(sect => {
|
||||||
const alreadyExists = sections.some((s: any) => s.label === sect);
|
sections.splice(index++, 0, {
|
||||||
if (!alreadyExists) {
|
label: sect,
|
||||||
sections.splice(index++, 0, {
|
title: sect,
|
||||||
label: sect,
|
settings: registeredSections[sect].map(a => a.key)
|
||||||
title: sect,
|
});
|
||||||
settings: registeredSections[sect].map(a => a.key)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
};
|
||||||
return ret;
|
|
||||||
}))};
|
|
||||||
Loading…
Add table
Reference in a new issue