This commit is contained in:
Mirco Wittrien 2020-06-22 11:06:06 +02:00
parent 785b6b4204
commit 07b0bebd34
3 changed files with 13 additions and 4 deletions

View File

@ -1718,6 +1718,15 @@
catch (err) {BDFDB.LogUtils.error("Could not create react element! " + err);} catch (err) {BDFDB.LogUtils.error("Could not create react element! " + err);}
return null; return null;
}; };
BDFDB.ReactUtils.objectToReact = function (obj) {
if (!obj) return null;
else if (typeof obj == "string") return obj;
else if (BDFDB.ObjectUtils.is(obj)) return BDFDB.ReactUtils.createElement(obj.type || obj.props && obj.props.href && "a" || "div", !obj.props ? {} : Object.assign({}, obj.props, {
children: obj.props.children ? BDFDB.ReactUtils.objectToReact(obj.props.children) : null
}));
else if (BDFDB.ArrayUtils.is(obj)) return obj.map(n => BDFDB.ReactUtils.objectToReact(n));
else return null;
};
BDFDB.ReactUtils.elementToReact = function (node, ref) { BDFDB.ReactUtils.elementToReact = function (node, ref) {
if (BDFDB.ReactUtils.isValidElement(node)) return node; if (BDFDB.ReactUtils.isValidElement(node)) return node;
else if (!Node.prototype.isPrototypeOf(node)) return null; else if (!Node.prototype.isPrototypeOf(node)) return null;

File diff suppressed because one or more lines are too long

View File

@ -12,13 +12,13 @@ var PersonalPins = (_ => {
getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";} getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";}
getVersion () {return "1.9.3";} getVersion () {return "1.9.4";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
constructor () { constructor () {
this.changelog = { this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]] "fixed":[["Crash Issue","Fixed a crash issue that occured on some rare occasions"]]
}; };
this.patchedModules = { this.patchedModules = {
@ -276,7 +276,7 @@ var PersonalPins = (_ => {
message.author = new BDFDB.DiscordObjects.User(message.author); message.author = new BDFDB.DiscordObjects.User(message.author);
message.timestamp = new BDFDB.DiscordObjects.Timestamp(message.timestamp); message.timestamp = new BDFDB.DiscordObjects.Timestamp(message.timestamp);
message.editedTimestamp = message.editedTimestamp && new BDFDB.DiscordObjects.Timestamp(message.editedTimestamp); message.editedTimestamp = message.editedTimestamp && new BDFDB.DiscordObjects.Timestamp(message.editedTimestamp);
if (message.customRenderedContent && message.customRenderedContent.content.length) message.customRenderedContent.content = message.customRenderedContent.content.filter(n => n).map(n => typeof n == "string" ? n : (n.props && n.props.href ? BDFDB.ReactUtils.createElement("a", n.props) : null)); if (message.customRenderedContent && message.customRenderedContent.content.length) message.customRenderedContent.content = BDFDB.ReactUtils.objectToReact(message.customRenderedContent.content);
for (let embed of message.embeds) { for (let embed of message.embeds) {
embed.color = typeof embed.color != "string" ? null : embed.color; embed.color = typeof embed.color != "string" ? null : embed.color;
embed.timestamp = embed.timestamp && new BDFDB.DiscordObjects.Timestamp(embed.timestamp); embed.timestamp = embed.timestamp && new BDFDB.DiscordObjects.Timestamp(embed.timestamp);