This commit is contained in:
Mirco Wittrien 2021-02-19 10:40:22 +01:00
parent 520443e205
commit cbada344d3
2 changed files with 10 additions and 7 deletions

View File

@ -7233,7 +7233,7 @@ module.exports = (_ => {
BDFDB.LibraryComponents = Object.assign({}, InternalComponents.LibraryComponents);
InternalBDFDB.createCustomControl = function (data) {
let controlButton = BDFDB.DOMUtils.create(`<${isBeta ? "button" : "div"} class="${BDFDB.DOMUtils.formatClassName(isBeta && BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton)}"></${isBeta ? "button" : "div"}>`);
let controlButton = BDFDB.DOMUtils.create(`<${isBeta ? "button" : "div"} class="${BDFDB.DOMUtils.formatClassName(isBeta && BDFDB.disCN._repobutton, BDFDB.disCN._repocontrolsbutton, BDFDB.disCN._repocontrolscustom)}"></${isBeta ? "button" : "div"}>`);
BDFDB.ReactUtils.render(BDFDB.ReactUtils.createElement(InternalComponents.LibraryComponents.SvgIcon, {
className: !isBeta && BDFDB.disCN._repoicon,
nativeClass: true,
@ -7246,12 +7246,12 @@ module.exports = (_ => {
return controlButton;
};
InternalBDFDB.appendCustomControls = function (card) {
if (!card || card.querySelector(BDFDB.dotCN._repocontrolscustom)) return;
let checkbox = card.querySelector(BDFDB.dotCN._reposwitch);
if (!checkbox) return;
let props = BDFDB.ObjectUtils.get(BDFDB.ReactUtils.getInstance(card), "return.stateNode.props");
let plugin = props && props.addon && (props.addon.plugin || props.addon.instance);
if (plugin && !props.hasCustomControls && (plugin == libraryInstance || plugin.name && plugin.name && PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin)) {
props.hasCustomControls = true;
if (plugin && (plugin == libraryInstance || plugin.name && plugin.name && PluginStores.loaded[plugin.name] && PluginStores.loaded[plugin.name] == plugin)) {
let url = InternalBDFDB.getPluginURL(plugin);
let controls = [];
let footerControls = card.querySelector("." + BDFDB.disCN._repofooter.split(" ")[0] + " " + BDFDB.dotCN._repocontrols);
@ -7271,11 +7271,12 @@ module.exports = (_ => {
};
InternalBDFDB.addListObserver = function (layer) {
if (!layer) return;
BDFDB.ObserverUtils.connect(BDFDB, layer, {name: "cardObserver", instance: new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(node => {
if (BDFDB.DOMUtils.containsClass(node, BDFDB.disCN._repocard)) InternalBDFDB.appendCustomControls(node);
if (node.nodeType != Node.TEXT_NODE) for (let child of node.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
BDFDB.ObserverUtils.connect(BDFDB, layer, {name: "cardObserver", instance: new MutationObserver(changes => {changes.forEach(change => {if (change.addedNodes) {change.addedNodes.forEach(n => {
if (BDFDB.DOMUtils.containsClass(n, BDFDB.disCN._repocard)) InternalBDFDB.appendCustomControls(n);
if (n.nodeType != Node.TEXT_NODE) for (let c of n.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(c);
InternalBDFDB.appendCustomControls(BDFDB.DOMUtils.getParent(BDFDB.dotCN._repocard, n));
});}});})}, {childList: true, subtree: true});
for (let child of layer.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(child);
for (let c of layer.querySelectorAll(BDFDB.dotCN._repocard)) InternalBDFDB.appendCustomControls(c);
}
const keyDownTimeouts = {};

View File

@ -500,6 +500,7 @@
"avatarDisabled": "disabled-6G33EE",
"badge": "badge-7R_W3s",
"badgeAvatar": "avatar-hF52Er",
"bdControlsCustom": "custom-L9FFs5",
"bdRepoEntry": "entry-9JnAPs",
"bdRepoFooterControls": "controls-p0SrvV",
"bdRepoHeaderControls": "controls-18FQsW",
@ -1362,6 +1363,7 @@
"_repocheckboxwrap": ["BDrepo", "switchWrapper"],
"_repocontrols": ["BDrepo", "bdControls"],
"_repocontrolsbutton": ["BDrepo", "bdControlsButton"],
"_repocontrolscustom": ["BDFDB", "bdControlsCustom"],
"_repodescription": ["BDrepo", "bdaDescription"],
"_repodescriptionwrap": ["BDrepo", "bdaDescriptionWrap"],
"_repoentry": ["BDFDB", "bdRepoEntry"],