Update 0BDFDB.plugin.js
This commit is contained in:
parent
9efb5a67ff
commit
1799e38311
|
@ -2163,11 +2163,9 @@ module.exports = (_ => {
|
|||
InternalBDFDB.patchComponent = function (pluginDataObjs, instance, type, config) {
|
||||
pluginDataObjs = [pluginDataObjs].flat(10).filter(n => n);
|
||||
if (pluginDataObjs.length && instance) {
|
||||
let name = type.split(" _ _ ")[0];
|
||||
instance = instance[BDFDB.ReactUtils.instanceKey] && instance[BDFDB.ReactUtils.instanceKey].type ? instance[BDFDB.ReactUtils.instanceKey].type : instance;
|
||||
instance = config.nonPrototype || BDFDB.ReactUtils.isCorrectInstance(instance, name) || InternalData.ModuleUtilsConfig.LoadedInComponents[type] ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up: true}));
|
||||
if (instance) {
|
||||
instance = instance[BDFDB.ReactUtils.instanceKey] && instance[BDFDB.ReactUtils.instanceKey].type ? instance[BDFDB.ReactUtils.instanceKey].type : instance;
|
||||
let name = type.split(" _ _ ")[0];
|
||||
let toBePatched = config.nonPrototype || !instance.prototype ? instance : instance.prototype;
|
||||
toBePatched = toBePatched && toBePatched.type && typeof toBePatched.type.render == "function" ? toBePatched.type : toBePatched;
|
||||
if (config.subComponent) {
|
||||
|
@ -2224,7 +2222,7 @@ module.exports = (_ => {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
else if (InternalBDFDB.isCorrectPatchInstance(ins, type)) {
|
||||
else {
|
||||
InternalBDFDB.patchComponent(pluginDataObjs, ins, type, config);
|
||||
BDFDB.PatchUtils.forceAllUpdates(pluginDataObjs.map(n => n.plugin), type);
|
||||
return true;
|
||||
|
@ -2232,17 +2230,13 @@ module.exports = (_ => {
|
|||
return false;
|
||||
};
|
||||
InternalBDFDB.checkForInstance = function (pluginData, type, config) {
|
||||
const app = document.querySelector(BDFDB.dotCN.app), bdSettings = document.querySelector("#bd-settingspane-container .scroller");
|
||||
let instanceFound = false;
|
||||
if (!config.forceObserve) {
|
||||
const app = document.querySelector(BDFDB.dotCN.app);
|
||||
if (app) {
|
||||
let appIns = BDFDB.ReactUtils.findConstructor(app, type, {unlimited: true}) || BDFDB.ReactUtils.findConstructor(app, type, {unlimited: true, up: true});
|
||||
if (appIns && (instanceFound = true)) InternalBDFDB.patchComponent(pluginData, appIns, type, config);
|
||||
}
|
||||
if (!instanceFound && bdSettings) {
|
||||
let bdSettingsIns = BDFDB.ReactUtils.findConstructor(bdSettings, type, {unlimited: true});
|
||||
if (bdSettingsIns && (instanceFound = true)) InternalBDFDB.patchComponent(pluginData, bdSettingsIns, type, config);
|
||||
}
|
||||
}
|
||||
if (!instanceFound) {
|
||||
let elementFound = false, classes = config.classNames.map(n => BDFDB.disCN[n]), selector = config.classNames.map(n => BDFDB.dotCN[n]).join(", ");
|
||||
|
@ -2279,13 +2273,6 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
InternalBDFDB.isCorrectPatchInstance = function (instance, name) {
|
||||
if (!instance) return false;
|
||||
instance = instance[BDFDB.ReactUtils.instanceKey] && instance[BDFDB.ReactUtils.instanceKey].type ? instance[BDFDB.ReactUtils.instanceKey].type : instance;
|
||||
instance = BDFDB.ReactUtils.isCorrectInstance(instance, name) ? instance : (BDFDB.ReactUtils.findConstructor(instance, name) || BDFDB.ReactUtils.findConstructor(instance, name, {up: true}));
|
||||
return !!instance;
|
||||
};
|
||||
|
||||
BDFDB.PatchUtils = {};
|
||||
BDFDB.PatchUtils.isPatched = function (plugin, module, methodName) {
|
||||
plugin = plugin == BDFDB && InternalBDFDB || plugin;
|
||||
|
|
Loading…
Reference in New Issue