Update ShowConnections.plugin.js

This commit is contained in:
Mirco Wittrien 2022-11-01 10:56:02 +01:00
parent 3722a0aef6
commit f69d547e99
1 changed files with 14 additions and 16 deletions

View File

@ -2,7 +2,7 @@
* @name ShowConnections * @name ShowConnections
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 1.1.4 * @version 1.1.5
* @description Shows the connected Accounts of a User in the UserPopout * @description Shows the connected Accounts of a User in the UserPopout
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -148,7 +148,7 @@ module.exports = (_ => {
this.modulePatches = { this.modulePatches = {
after: [ after: [
"UserPopoutBody", "UserPopoutBody",
"UserRolesSection" "UserConnectionsSection"
] ]
}; };
@ -156,7 +156,6 @@ module.exports = (_ => {
general: { general: {
useColoredIcons: {value: true, description: "Uses colored Version of the Icons"}, useColoredIcons: {value: true, description: "Uses colored Version of the Icons"},
useColoredTooltips: {value: true, description: "Uses colored Version of the Tooltips"}, useColoredTooltips: {value: true, description: "Uses colored Version of the Tooltips"},
placeAtTop: {value: false, description: "Places the Connections at the Top of the UserPopout Body"},
showVerifiedBadge: {value: true, description: "Shows the Badge for verified Connections"}, showVerifiedBadge: {value: true, description: "Shows the Badge for verified Connections"},
openWebpage: {value: true, description: "Opens the Connection Page when clicking the Icon"} openWebpage: {value: true, description: "Opens the Connection Page when clicking the Icon"}
}, },
@ -238,21 +237,20 @@ module.exports = (_ => {
}); });
} }
processUserRolesSection (e) { processUserConnectionsSection (e) {
if (!e.instance.props.user || e.instance.props.user.isNonUserBot()) return; let user = e.instance.props.user || BDFDB.LibraryStores.UserStore.getUser(e.instance.props.userId);
if (!loadedUsers[e.instance.props.user.id] && !requestedUsers[e.instance.props.user.id]) { if (!user || user.isNonUserBot()) return;
requestedUsers[e.instance.props.user.id] = true; if (!loadedUsers[user.id] && !requestedUsers[user.id]) {
queuedInstances[e.instance.props.user.id] = [].concat(queuedInstances[e.instance.props.user.id]).filter(n => n); requestedUsers[user.id] = true;
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id); queuedInstances[user.id] = [].concat(queuedInstances[user.id]).filter(n => n);
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(user.id);
} }
let connections = BDFDB.ReactUtils.createElement(UserConnectionsComponents, {
user: e.instance.props.user
}, true);
e.returnvalue = [ e.returnvalue = [
this.settings.general.placeAtTop && connections,
e.returnvalue, e.returnvalue,
!this.settings.general.placeAtTop && connections BDFDB.ReactUtils.createElement(UserConnectionsComponents, {
].filter(n => n); user: user
}, true)
];
} }
processUserPopoutBody (e) { processUserPopoutBody (e) {
@ -263,7 +261,7 @@ module.exports = (_ => {
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id); BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id);
} }
let bodyInner = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutbodyinnerwrapper]]}); let bodyInner = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.userpopoutbodyinnerwrapper]]});
if (bodyInner) bodyInner.props.children.splice(this.settings.general.placeAtTop ? 1 : bodyInner.props.children.length - 2, 0, BDFDB.ReactUtils.createElement(UserConnectionsComponents, { if (bodyInner) bodyInner.props.children.splice(bodyInner.props.children.length - 2, 0, BDFDB.ReactUtils.createElement(UserConnectionsComponents, {
old: true, old: true,
user: e.instance.props.user user: e.instance.props.user
}, true)); }, true));