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

File diff suppressed because one or more lines are too long