Add compatibility with existing bdcontextmenu
This commit is contained in:
parent
97b486657f
commit
b60e1cbc91
|
@ -8,13 +8,12 @@ import ContextMenuPatcher from "@modules/api/contextmenu";
|
||||||
import pluginManager from "@modules/pluginmanager";
|
import pluginManager from "@modules/pluginmanager";
|
||||||
import themeManager from "@modules/thememanager";
|
import themeManager from "@modules/thememanager";
|
||||||
import Utilities from "@modules/utilities";
|
import Utilities from "@modules/utilities";
|
||||||
|
import React from "@modules/react";
|
||||||
|
|
||||||
|
|
||||||
const ContextMenu = new ContextMenuPatcher();
|
const ContextMenu = new ContextMenuPatcher();
|
||||||
const UserSettingsWindow = Webpack.getByProps("open", "updateAccount");
|
const UserSettingsWindow = Webpack.getByProps("open", "updateAccount");
|
||||||
|
|
||||||
const SEPARATOR_ITEM = ContextMenu.buildItem({type: "separator"});
|
|
||||||
|
|
||||||
export default new class BDContextMenu extends Builtin {
|
export default new class BDContextMenu extends Builtin {
|
||||||
get name() {return "BDContextMenu";}
|
get name() {return "BDContextMenu";}
|
||||||
get category() {return "general";}
|
get category() {return "general";}
|
||||||
|
@ -23,16 +22,6 @@ export default new class BDContextMenu extends Builtin {
|
||||||
constructor() {
|
constructor() {
|
||||||
super(...arguments);
|
super(...arguments);
|
||||||
this.callback = this.callback.bind(this);
|
this.callback = this.callback.bind(this);
|
||||||
|
|
||||||
this.UPDATES_ITEM = {
|
|
||||||
label: Strings.Panels.updates,
|
|
||||||
action: () => this.openCategory("updates")
|
|
||||||
};
|
|
||||||
|
|
||||||
this.CUSTOM_CSS_ITEM = {
|
|
||||||
label: Strings.Panels.customcss,
|
|
||||||
action: () => this.openCategory("customcss")
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled() {
|
enabled() {
|
||||||
|
@ -47,22 +36,34 @@ export default new class BDContextMenu extends Builtin {
|
||||||
const target = Utilities.findInTree(retVal, b => Array.isArray(b) && b.some(e => e?.key?.toLowerCase() === "my_account"), {walkable: ["props", "children"]});
|
const target = Utilities.findInTree(retVal, b => Array.isArray(b) && b.some(e => e?.key?.toLowerCase() === "my_account"), {walkable: ["props", "children"]});
|
||||||
if (!target) return;
|
if (!target) return;
|
||||||
|
|
||||||
|
// Prevent conflict with plugin until its eradicated
|
||||||
|
if (target.some(e => e.props.label.toLowerCase() === "betterdiscord")) return;
|
||||||
|
|
||||||
// BetterDiscord Settings
|
// BetterDiscord Settings
|
||||||
const items = Settings.collections.map(c => this.buildCollectionMenu(c));
|
const items = Settings.collections.map(c => this.buildCollectionMenu(c));
|
||||||
|
|
||||||
// Updater
|
// Updater
|
||||||
items.push(this.UPDATES_ITEM);
|
items.push({
|
||||||
|
label: Strings.Panels.updates,
|
||||||
|
action: () => this.openCategory("updates")
|
||||||
|
});
|
||||||
|
|
||||||
// Custom CSS
|
// Custom CSS
|
||||||
if (Settings.get("settings", "customcss", "customcss")) items.push(this.CUSTOM_CSS_ITEM);
|
if (Settings.get("settings", "customcss", "customcss")) {
|
||||||
|
items.push({
|
||||||
|
label: Strings.Panels.customcss,
|
||||||
|
action: () => this.openCategory("customcss")
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Plugins & Themes
|
// Plugins & Themes
|
||||||
items.push(this.buildAddonMenu(Strings.Panels.plugins, pluginManager));
|
items.push(this.buildAddonMenu(Strings.Panels.plugins, pluginManager));
|
||||||
items.push(this.buildAddonMenu(Strings.Panels.themes, themeManager));
|
items.push(this.buildAddonMenu(Strings.Panels.themes, themeManager));
|
||||||
|
|
||||||
// Parent SubMenu
|
// Parent SubMenu
|
||||||
target.push(SEPARATOR_ITEM);
|
const bdSubMenu = ContextMenu.buildItem({type: "submenu", label: "BetterDiscord", items: items});
|
||||||
target.push(ContextMenu.buildItem({type: "submenu", label: "BetterDiscord", items: items}));
|
const bdGroup = React.createElement(ContextMenu.Group, null, [bdSubMenu]);
|
||||||
|
target.push(bdGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
buildCollectionMenu(collection) {
|
buildCollectionMenu(collection) {
|
||||||
|
|
Loading…
Reference in New Issue