Update ShowConnections.plugin.js
This commit is contained in:
parent
fe28b94e9c
commit
9380d877d3
|
@ -2,7 +2,7 @@
|
|||
* @name ShowConnections
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 1.0.4
|
||||
* @version 1.0.5
|
||||
* @description Shows the connected Accounts of a User in the UserPopout
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,17 +17,13 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ShowConnections",
|
||||
"author": "DevilBro",
|
||||
"version": "1.0.4",
|
||||
"version": "1.0.5",
|
||||
"description": "Shows the connected Accounts of a User in the UserPopout"
|
||||
},"description": "Displays the Last Message Date of a Member for the current Server/DM in the UserPopout and UserModal"
|
||||
},
|
||||
"changeLog": {
|
||||
"improved": {
|
||||
"Tooltip Color": "Slighty darkened the Tooltip Color to increase Readability"
|
||||
},
|
||||
"added": {
|
||||
"Filter": "You can now enable/disable certain Connections so they don't show",
|
||||
"Position": "You can now change the order and place them at the top of the UserPopout",
|
||||
"Customization": "You can now disable the Tooltip Color, change the Icons to a white Version, disable the Verified Badge",
|
||||
"fixed": {
|
||||
"User Popout": "Fixing Stuff for the User Popout Update, thanks Discord"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -78,13 +74,14 @@ module.exports = (_ => {
|
|||
return template.content.firstElementChild;
|
||||
}
|
||||
} : (([Plugin, BDFDB]) => {
|
||||
var loadedUsers = {}, fetchTimeout, currentPopup = {};
|
||||
var loadedUsers = {}, fetchTimeout, currentPopout;
|
||||
|
||||
return class ShowConnections extends Plugin {
|
||||
onLoad () {
|
||||
this.patchedModules = {
|
||||
after: {
|
||||
UserPopout: ["render", "componentDidMount"]
|
||||
AnalyticsContext: "render",
|
||||
UserPopoutBody: "default"
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -130,9 +127,9 @@ module.exports = (_ => {
|
|||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dispatch", {after: e => {
|
||||
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == BDFDB.DiscordConstants.ActionTypes.USER_PROFILE_FETCH_SUCCESS && e.methodArguments[0].user && e.methodArguments[0].connected_accounts) {
|
||||
loadedUsers[e.methodArguments[0].user.id] = e.methodArguments[0].connected_accounts;
|
||||
if (currentPopup.id == e.methodArguments[0].user.id) {
|
||||
BDFDB.ReactUtils.forceUpdate(currentPopup.instance);
|
||||
currentPopup = {};
|
||||
if (currentPopout && currentPopout.user.id == e.methodArguments[0].user.id) {
|
||||
BDFDB.ReactUtils.forceUpdate(currentPopout.instance);
|
||||
currentPopout = null;
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
@ -179,18 +176,28 @@ module.exports = (_ => {
|
|||
});
|
||||
}
|
||||
|
||||
processUserPopout (e) {
|
||||
if (e.instance.props.user && !e.instance.props.user.bot && e.instance.props.user.discriminator != "0000") {
|
||||
if (e.node) currentPopup = {id: e.instance.props.user.id, instance: e.instance};
|
||||
else {
|
||||
processAnalyticsContext (e) {
|
||||
if (e.instance.props.section != BDFDB.DiscordConstants.AnalyticsSections.PROFILE_POPOUT) return;
|
||||
const user = BDFDB.ReactUtils.findValue(e.instance, "user");
|
||||
if (!user) return;
|
||||
currentPopout = {user: user, instance: e.instance};
|
||||
}
|
||||
|
||||
processUserPopoutBody (e) {
|
||||
if (!e.instance.props.user || e.instance.props.user.bot || e.instance.props.user.discriminator == "0000") return;
|
||||
if (loadedUsers[e.instance.props.user.id]) {
|
||||
let connections = loadedUsers[e.instance.props.user.id].filter(c => this.settings.connections[c.type]);
|
||||
if (connections.length) {
|
||||
if (!connections.length) return;
|
||||
let isLightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
||||
let bodyInner = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutbodyinnerwrapper]]});
|
||||
if (bodyInner) bodyInner.props.children.splice(this.settings.general.placeAtTop ? 0 : bodyInner.props.children.length - 1, 0, [
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
console.log(bodyInner.props.children);
|
||||
if (bodyInner) bodyInner.props.children.splice(this.settings.general.placeAtTop ? 1 : bodyInner.props.children.length - 2, 0, BDFDB.ReactUtils.createElement(BDFDB.ReactUtils.Fragment, {
|
||||
children: [
|
||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Header, {
|
||||
className: BDFDB.disCN.userpopoutbodytitle,
|
||||
size: BDFDB.LibraryComponents.Header.Sizes.SIZE_12,
|
||||
muted: true,
|
||||
uppercase: true,
|
||||
children: BDFDB.LanguageUtils.LanguageStrings.CONNECTIONS
|
||||
}),
|
||||
BDFDB.ReactUtils.createElement("div", {
|
||||
|
@ -231,8 +238,8 @@ module.exports = (_ => {
|
|||
});
|
||||
})
|
||||
})
|
||||
]);
|
||||
}
|
||||
]
|
||||
}));
|
||||
}
|
||||
else {
|
||||
BDFDB.TimeUtils.clear(fetchTimeout);
|
||||
|
@ -241,8 +248,6 @@ module.exports = (_ => {
|
|||
}, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window.BDFDB_Global.PluginUtils.buildPlugin(config));
|
||||
})();
|
||||
|
|
Loading…
Reference in New Issue