This commit is contained in:
Mirco Wittrien 2020-02-07 19:20:01 +01:00
parent e5d171c9a0
commit 201d1d18c1
2 changed files with 20 additions and 14 deletions

View File

@ -1034,6 +1034,7 @@
"DiscordTag",
"InviteModalUserRow",
"NameTag",
"Mention",
"Message",
"MessageHeader",
"MessageTimestamp",
@ -1642,6 +1643,7 @@
if (propValue != null) node.style.setProperty(key, propValue, "important");
}
};
console.log(reactEle);
};
BDFDB.ReactUtils.findChildren = function (nodeOrInstance, config) {
if (!nodeOrInstance || !BDFDB.ObjectUtils.is(config) || !config.name && !config.key && !config.props && !config.filter) return [null, -1];
@ -1992,21 +1994,25 @@
}
};
let MessageRerenderTimeout;
BDFDB.MessageUtils = {};
BDFDB.MessageUtils.rerenderAll = function () {
let MessagesIns = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Messages", unlimited:true});
let MessagesPrototype = BDFDB.ReactUtils.getValue(MessagesIns, "_reactInternalFiber.type.prototype");
if (MessagesIns && MessagesPrototype) {
let patchCancel = BDFDB.ModuleUtils.patch({name:"tempPatch"}, MessagesPrototype, "render", {after:e => {
patchCancel();
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnValue, {props: ["message", "channel"]});
if (index > -1) {
for (let i in children) children[i].props.message = new BDFDB.DiscordObjects.Message({author: new BDFDB.DiscordObjects.User({})});
BDFDB.ReactUtils.forceUpdate(e.thisObject);
}
}});
BDFDB.ReactUtils.forceUpdate(MessagesIns);
}
BDFDB.TimeUtils.clear(MessageRerenderTimeout);
MessageRerenderTimeout = BDFDB.TimeUtils.timeout(_ => {
let MessagesIns = BDFDB.ReactUtils.findOwner(document.querySelector(BDFDB.dotCN.app), {name:"Messages", unlimited:true});
let MessagesPrototype = BDFDB.ReactUtils.getValue(MessagesIns, "_reactInternalFiber.type.prototype");
if (MessagesIns && MessagesPrototype) {
let patchCancel = BDFDB.ModuleUtils.patch({name:"tempPatch"}, MessagesPrototype, "render", {after:e => {
patchCancel();
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnValue, {props: ["message", "channel"]});
if (index > -1) {
for (let i in children) children[i].props.message = new BDFDB.DiscordObjects.Message({author: new BDFDB.DiscordObjects.User({})});
BDFDB.ReactUtils.forceUpdate(e.thisObject);
}
}});
BDFDB.ReactUtils.forceUpdate(MessagesIns);
}
}, 3000);
};
BDFDB.UserUtils = {};

File diff suppressed because one or more lines are too long