Fix context menus (#1600)
* Fix context menus * bump changelog & version --------- Co-authored-by: Strencher <46447572+Strencher@users.noreply.github.com>
This commit is contained in:
parent
2fbd3c6090
commit
900df71f20
11
CHANGELOG.md
11
CHANGELOG.md
|
@ -2,6 +2,17 @@
|
|||
|
||||
This changelog starts with the restructured 1.0.0 release that happened after context isolation changes. The changelogs here should more-or-less mirror the ones that get shown in the client but probably with less formatting and pizzazz.
|
||||
|
||||
## 1.9.2
|
||||
|
||||
### Added
|
||||
|
||||
### Removed
|
||||
|
||||
### Changed
|
||||
|
||||
### Fixed
|
||||
- Fixed context menu crash & api
|
||||
|
||||
## 1.9.1
|
||||
|
||||
### Added
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "betterdiscord",
|
||||
"version": "1.9.1",
|
||||
"version": "1.9.2",
|
||||
"description": "Enhances Discord by adding functionality and themes.",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -2,18 +2,18 @@
|
|||
export default {
|
||||
description: "Hotfix!",
|
||||
changes: [
|
||||
{
|
||||
title: "What's New?",
|
||||
type: "improved",
|
||||
items: [
|
||||
"Added SourceURL for the renderer. This makes it easier for developers to identify BD in call stacks.",
|
||||
]
|
||||
},
|
||||
// {
|
||||
// title: "What's New?",
|
||||
// type: "improved",
|
||||
// items: [
|
||||
// "Added SourceURL for the renderer. This makes it easier for developers to identify BD in call stacks.",
|
||||
// ]
|
||||
// },
|
||||
{
|
||||
title: "Bug Fixes",
|
||||
type: "fixed",
|
||||
items: [
|
||||
"Fixed immediate crashes.",
|
||||
"Fixed context menu crashes & api",
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -5,43 +5,18 @@ import {React} from "../modules";
|
|||
|
||||
let startupComplete = false;
|
||||
|
||||
const MenuComponents = (() => {
|
||||
const out = {};
|
||||
const componentMap = {
|
||||
separator: "Separator",
|
||||
checkbox: "CheckboxItem",
|
||||
radio: "RadioItem",
|
||||
control: "ControlItem",
|
||||
groupstart: "Group",
|
||||
customitem: "Item"
|
||||
};
|
||||
const ModulesBundle = WebpackModules.getByProps("MenuItem", "Menu");
|
||||
const MenuComponents = {
|
||||
Separator: ModulesBundle?.MenuSeparator,
|
||||
CheckboxItem: ModulesBundle?.MenuCheckboxItem,
|
||||
RadioItem: ModulesBundle?.MenuRadioItem,
|
||||
ControlItem: ModulesBundle?.MenuControlItem,
|
||||
Group: ModulesBundle?.MenuGroup,
|
||||
Item: ModulesBundle?.MenuItem,
|
||||
Menu: ModulesBundle?.Menu,
|
||||
};
|
||||
|
||||
// exportKey:()=>identifier
|
||||
const getExportIdentifier = (string, id) => new RegExp(`(\\w+):\\(\\)=>${id}`).exec(string)?.[1];
|
||||
|
||||
try {
|
||||
let contextMenuId = Object.keys(WebpackModules.require.m).find(e => WebpackModules.require.m[e]?.toString().includes("menuitemcheckbox"));
|
||||
const ContextMenuModule = WebpackModules.getModule((m, t, id) => id === contextMenuId);
|
||||
const rawMatches = WebpackModules.require.m[contextMenuId].toString().matchAll(/if\(\w+\.type===(\w+)\)[\s\S]+?type:"(.+?)"/g);
|
||||
const moduleString = WebpackModules.require.m[contextMenuId].toString();
|
||||
out.Menu = Object.values(ContextMenuModule).find(v => v.toString().includes(".isUsingKeyboardNavigation"));
|
||||
|
||||
for (const [, identifier, type] of rawMatches) {
|
||||
out[componentMap[type]] = ContextMenuModule[getExportIdentifier(moduleString, identifier)];
|
||||
}
|
||||
|
||||
startupComplete = Object.values(componentMap).every(k => out[k]) && !!out.Menu;
|
||||
} catch (error) {
|
||||
startupComplete = false;
|
||||
Logger.stacktrace("ContextMenu~Components", "Fatal startup error:", error);
|
||||
|
||||
Object.assign(out, Object.fromEntries(
|
||||
Object.values(componentMap).map(k => [k, () => null])
|
||||
));
|
||||
}
|
||||
|
||||
return out;
|
||||
})();
|
||||
startupComplete = Object.values(MenuComponents).every(v => v);
|
||||
|
||||
const ContextMenuActions = (() => {
|
||||
const out = {};
|
||||
|
|
Loading…
Reference in New Issue