pc gon die gotta stop

master^2
Cain Atkinson 2 years ago
parent 701182ab7f
commit 529582bb3b

@ -4,7 +4,12 @@ import webpack from "./webpack";
const settingsSym = Symbol("__settings");
const settingsView = webpack.find(m => m.default && m.default.displayName === "SettingsView");
// super secret value that shouldnt be exposed, used internally to avoid section conflicts and the like
const ovrwrtSctnSym: symbol = Symbol("__overwriteSection");
const settingsView = webpack.find(
(m) => m.default && m.default.displayName === "SettingsView"
);
type getPredicateSectionsEntry =
| {
@ -22,7 +27,7 @@ type getPredicateSectionsEntry =
function patch(args: mixed, ret: getPredicateSectionsEntry[]) {
const processedEntries = window.demon[settingsSym].entries.map((e) => ({
section: "DEMON_SETTINGS_LOADER_" + e.name,
section: e[ovrwrtSctnSym] ?? "DEMON_SETTINGS_LOADER_" + e.name,
label: e.name,
element: e.component,
}));
@ -63,9 +68,18 @@ function unregisterSettingsEntry(name: string) {
s.entries = s.entries.filter((e) => e.name !== name);
}
function registerSettingsEntry(name: string, component: Function): () => void {
window.demon[settingsSym].entries.push({ name, component });
function registerSettingsEntry(name: string, section: string, component: Function): () => void {
let entry = { name, component };
if (section)
entry[ovrwrtSctnSym] = section;
window.demon[settingsSym].entries.push(entry);
return () => unregisterSettingsEntry(name);
}
export default { init, unInit, registerSettingsEntry, unregisterSettingsEntry };
export default {
init,
unInit,
registerSettingsEntry,
unregisterSettingsEntry,
ovrwrtSctnSymm: ovrwrtSctnSym,
};

@ -46,8 +46,8 @@ async function init(obj: Object): Promise<void> {
},
};
commands.init(obj);
plugins.init(obj);
settingsInj.init();
plugins.init(obj);
}
export default init;

Loading…
Cancel
Save