Update FriendNotifications.plugin.js

This commit is contained in:
Mirco Wittrien 2020-11-16 10:00:48 +01:00
parent d18cc4150e
commit 298754d8b6
1 changed files with 17 additions and 4 deletions

View File

@ -14,12 +14,12 @@ module.exports = (_ => {
"info": {
"name": "FriendNotifications",
"author": "DevilBro",
"version": "1.5.2",
"version": "1.5.3",
"description": "Get a notification when a Friend or a User you choose to observe changes their online status, can be configured individually in the settings"
},
"changeLog": {
"fixed": {
"Crash on Canary": "Fixed the crash issue that occured one some plugins on canary"
"Works again": "Can discord stop messing with the server list, jeez"
}
}
};
@ -493,14 +493,27 @@ module.exports = (_ => {
let childrenRender = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let children = childrenRender(...args);
this.injectCounter(children);
this.checkTree(children);
return children;
};
}
else this.injectCounter(e.returnvalue);
else this.checkTree(e.returnvalue);
}
}
checkTree (returnvalue) {
let tree = BDFDB.ReactUtils.findChild(returnvalue, {filter: n => n && n.props && typeof n.props.children == "function"});
if (tree) {
let childrenRender = tree.props.children;
tree.props.children = (...args) => {
let children = childrenRender(...args);
this.injectCounter(children);
return children;
};
}
else this.injectCounter(returnvalue);
}
injectCounter (returnvalue) {
let [children, index] = BDFDB.ReactUtils.findParent(returnvalue, {name: "ConnectedUnreadDMs"});
if (index > -1) children.splice(index, 0, BDFDB.ReactUtils.createElement(FriendOnlineCounterComponent, {