stuff
This commit is contained in:
parent
c4aaf5f3fe
commit
b213fe1d7f
|
@ -356,6 +356,7 @@
|
||||||
"ChannelTextAreaEditor": {"strings": ["onHideAutocomplete", "onMaybeShowAutocomplete", "uploadPromptCharacterCount", "_focusBlurQueue"]},
|
"ChannelTextAreaEditor": {"strings": ["onHideAutocomplete", "onMaybeShowAutocomplete", "uploadPromptCharacterCount", "_focusBlurQueue"]},
|
||||||
"ChannelTextAreaForm": {"strings": ["renderApplicationCommandIcon", "handleTextareaChange", "handleSendMessage"]},
|
"ChannelTextAreaForm": {"strings": ["renderApplicationCommandIcon", "handleTextareaChange", "handleSendMessage"]},
|
||||||
"ConnectedLazyImageZoomable": {"strings": ["{isWindowFocused", ",appContext:"]},
|
"ConnectedLazyImageZoomable": {"strings": ["{isWindowFocused", ",appContext:"]},
|
||||||
|
"CustomStatusModal": {"protos": ["renderCustomStatusInput", "renderClearAfter", "getEmojiButtonRenderer"]},
|
||||||
"DirectMessage": {"strings": ["getRecipientId", "Controller", "handleContextMenu", ".DM"]},
|
"DirectMessage": {"strings": ["getRecipientId", "Controller", "handleContextMenu", ".DM"]},
|
||||||
"DiscordTag": {"strings": ["hidePersonalInformation", "isVerifiedBot", "botType"]},
|
"DiscordTag": {"strings": ["hidePersonalInformation", "isVerifiedBot", "botType"]},
|
||||||
"Embed": {"strings": ["gridContainer", "renderEmbedContent", "hasThumbnail"]},
|
"Embed": {"strings": ["gridContainer", "renderEmbedContent", "hasThumbnail"]},
|
||||||
|
@ -384,6 +385,7 @@
|
||||||
"MessageSearchResultContextMenu": {"strings": ["MESSAGE_ACTIONS_MENU_LABEL", "navId:\"message"], "nonStrings": ["getGuildId"]},
|
"MessageSearchResultContextMenu": {"strings": ["MESSAGE_ACTIONS_MENU_LABEL", "navId:\"message"], "nonStrings": ["getGuildId"]},
|
||||||
"MessageToolbar": {"strings": ["Messages.MORE", "hasDeveloperMode", "openPopoutType"]},
|
"MessageToolbar": {"strings": ["Messages.MORE", "hasDeveloperMode", "openPopoutType"]},
|
||||||
"ModalCarousel": {"strings": [".gotoNext", "currentIndex", "gotoPrevThrottled"]},
|
"ModalCarousel": {"strings": [".gotoNext", "currentIndex", "gotoPrevThrottled"]},
|
||||||
|
"ModalFooter": {"strings": [".footerSeparator", ".separator", "Direction.HORIZONTAL_REVERSE"]},
|
||||||
"NowPlayingHeader": {"strings": ["ACTIVITY_FEED_NOW_PLAYING_HEADER", "partiedMembers"]},
|
"NowPlayingHeader": {"strings": ["ACTIVITY_FEED_NOW_PLAYING_HEADER", "partiedMembers"]},
|
||||||
"NowPlayingItem": {"strings": [".wrapper", "padded:"]},
|
"NowPlayingItem": {"strings": [".wrapper", "padded:"]},
|
||||||
"PanelButton": {"strings": ["Masks.PANEL_BUTTON"]},
|
"PanelButton": {"strings": ["Masks.PANEL_BUTTON"]},
|
||||||
|
@ -409,14 +411,17 @@
|
||||||
"UnreadDMs": {"strings": ["getMutablePrivateChannels", "selectedVoiceGuildId", ".selectedVoiceChannelId"]},
|
"UnreadDMs": {"strings": ["getMutablePrivateChannels", "selectedVoiceGuildId", ".selectedVoiceChannelId"]},
|
||||||
"UseCopyIdItem": {"strings": ["\"devmode-copy-id\""]},
|
"UseCopyIdItem": {"strings": ["\"devmode-copy-id\""]},
|
||||||
"UserBanner": {"strings": [".bannerSrc", ".viewerPremiumOverride", ".SETTINGS"]},
|
"UserBanner": {"strings": [".bannerSrc", ".viewerPremiumOverride", ".SETTINGS"]},
|
||||||
|
"UserBioSection": {"strings": [".isUsingGuildBio", "aboutMeGuildIcon", "GUILD_IDENTITY_BIO_TOAST"]},
|
||||||
"UserGenericContextMenu": {"strings": ["USER_ACTIONS_MENU_LABEL", "navId:\"user", ".USER_GENERIC_MENU"]},
|
"UserGenericContextMenu": {"strings": ["USER_ACTIONS_MENU_LABEL", "navId:\"user", ".USER_GENERIC_MENU"]},
|
||||||
"UserMemberContextMenu": {"strings": ["USER_ACTIONS_MENU_LABEL", "navId:\"user", ".GUILD_CHANNEL_USER_MENU"]},
|
"UserMemberContextMenu": {"strings": ["USER_ACTIONS_MENU_LABEL", "navId:\"user", ".GUILD_CHANNEL_USER_MENU"]},
|
||||||
"UsernameSection": {"strings": [".shouldCopyOnClick", ".userTagDiscriminatorNoNickname"]},
|
"UsernameSection": {"strings": [".shouldCopyOnClick", ".userTagDiscriminatorNoNickname"]},
|
||||||
"UserPopoutAvatar": {"strings": ["isNonUserBot", "avatarHintInnerText", "avatarDecorationHint"]},
|
"UserPopoutAvatar": {"strings": ["isNonUserBot", "avatarHintInnerText", "avatarDecorationHint"]},
|
||||||
|
"UserPopoutBody": {"strings": ["isNonUserBot", "customStatusActivity", "bodyInnerWrapper"]},
|
||||||
"UserPopoutInfo": {"strings": [".hasCustomStatus", ".premiumGuildSince", "openPremiumSettings"]},
|
"UserPopoutInfo": {"strings": [".hasCustomStatus", ".premiumGuildSince", "openPremiumSettings"]},
|
||||||
"UserProfileModalHeader": {"strings": [".friendToken", ".additionalActionsIcon", "onMessage"]},
|
"UserProfileModalHeader": {"strings": [".friendToken", ".additionalActionsIcon", "onMessage"]},
|
||||||
"UserSummaryItem": {"protos": ["renderMoreUsers", "renderUsers", "renderIcon"]},
|
"UserSummaryItem": {"protos": ["renderMoreUsers", "renderUsers", "renderIcon"]},
|
||||||
"UserThemedBanner": {"strings": [".showPremiumBadgeUpsell", ".isPremiumAtLeast", ".SETTINGS"]},
|
"UserThemedBanner": {"strings": [".showPremiumBadgeUpsell", ".isPremiumAtLeast", ".SETTINGS"]},
|
||||||
|
"UserThemedPopoutBody": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation"]},
|
||||||
"UserThemedPopoutHeader": {"strings": [".avatarPositionPremiumNoBanner", "syncProfileThemeWithUserTheme"]},
|
"UserThemedPopoutHeader": {"strings": [".avatarPositionPremiumNoBanner", "syncProfileThemeWithUserTheme"]},
|
||||||
"VoiceUser": {"protos": ["renderPrioritySpeaker", "renderIcons", "renderAvatar"]},
|
"VoiceUser": {"protos": ["renderPrioritySpeaker", "renderIcons", "renderAvatar"]},
|
||||||
"VoiceUsers": {"strings": ["hidePreview", "previewIsOpen", "previewUserIdAfterDelay"]}
|
"VoiceUsers": {"strings": ["hidePreview", "previewIsOpen", "previewUserIdAfterDelay"]}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @name ShowConnections
|
* @name ShowConnections
|
||||||
* @author DevilBro
|
* @author DevilBro
|
||||||
* @authorId 278543574059057154
|
* @authorId 278543574059057154
|
||||||
* @version 1.1.2
|
* @version 1.1.3
|
||||||
* @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
|
||||||
|
@ -59,220 +59,21 @@ module.exports = (_ => {
|
||||||
var _this;
|
var _this;
|
||||||
var loadedUsers, requestedUsers, queuedInstances;
|
var loadedUsers, requestedUsers, queuedInstances;
|
||||||
|
|
||||||
return class ShowConnections extends Plugin {
|
const UserConnectionsComponents = class UserConnections extends BdApi.React.Component {
|
||||||
onLoad () {
|
|
||||||
_this = this;
|
|
||||||
loadedUsers = {};
|
|
||||||
requestedUsers = {};
|
|
||||||
queuedInstances = {};
|
|
||||||
|
|
||||||
this.patchedModules = {
|
|
||||||
after: {
|
|
||||||
UserPopoutBodySection: "default",
|
|
||||||
UserPopoutBody: "default"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.defaults = {
|
|
||||||
general: {
|
|
||||||
useColoredIcons: {value: true, description: "Uses colored Version of the Icons"},
|
|
||||||
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"},
|
|
||||||
openWebpage: {value: true, description: "Opens the Connection Page when clicking the Icon"}
|
|
||||||
},
|
|
||||||
connections: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (let connection of BDFDB.LibraryModules.ConnectionProviderUtils.filter(n => n)) this.defaults.connections[connection.type] = Object.assign({}, connection, {value: true});
|
|
||||||
|
|
||||||
this.css = `
|
|
||||||
${BDFDB.dotCN._showconnectionsconnections} {
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 6px;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN._showconnectionsconnection} {
|
|
||||||
position: relative;
|
|
||||||
width: 28px;
|
|
||||||
height: 28px;
|
|
||||||
margin: 4px 10px 6px 0;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN._showconnectionsicon} {
|
|
||||||
margin: -15% 0 0 -15%;
|
|
||||||
width: 130%;
|
|
||||||
height: 130%;
|
|
||||||
}
|
|
||||||
${BDFDB.dotCN._showconnectionsverifiedbadge} {
|
|
||||||
position: absolute;
|
|
||||||
bottom: -10%;
|
|
||||||
right: -10%;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
|
|
||||||
onStart () {
|
|
||||||
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dispatch", {after: e => {
|
|
||||||
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == "USER_PROFILE_FETCH_SUCCESS" && e.methodArguments[0].user && e.methodArguments[0].connected_accounts) {
|
|
||||||
const user = e.methodArguments[0].user;
|
|
||||||
delete requestedUsers[user.id];
|
|
||||||
loadedUsers[user.id] = e.methodArguments[0].connected_accounts;
|
|
||||||
BDFDB.ReactUtils.forceUpdate(queuedInstances[user.id]);
|
|
||||||
delete queuedInstances[user.id];
|
|
||||||
}
|
|
||||||
}});
|
|
||||||
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
onStop () {
|
|
||||||
BDFDB.PatchUtils.forceAllUpdates(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
getSettingsPanel (collapseStates = {}) {
|
|
||||||
let settingsPanel;
|
|
||||||
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
|
||||||
collapseStates: collapseStates,
|
|
||||||
children: _ => {
|
|
||||||
let settingsItems = [];
|
|
||||||
|
|
||||||
for (let key in this.defaults.general) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
|
||||||
type: "Switch",
|
|
||||||
plugin: this,
|
|
||||||
keys: ["general", key],
|
|
||||||
label: this.defaults.general[key].description,
|
|
||||||
value: this.settings.general[key]
|
|
||||||
}));
|
|
||||||
|
|
||||||
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
|
||||||
title: "Display Connections:",
|
|
||||||
children: Object.keys(this.defaults.connections).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
|
||||||
type: "Switch",
|
|
||||||
plugin: this,
|
|
||||||
keys: ["connections", key],
|
|
||||||
label: this.defaults.connections[key].name,
|
|
||||||
value: this.settings.connections[key],
|
|
||||||
labelChildren: [
|
|
||||||
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.lightSVG}),
|
|
||||||
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.whiteSVG})
|
|
||||||
]
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
|
|
||||||
return settingsItems;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
processUserPopoutBodySection (e) {
|
|
||||||
if (!e.instance.props.user || e.instance.props.user.isNonUserBot()) return;
|
|
||||||
if (!loadedUsers[e.instance.props.user.id] && !requestedUsers[e.instance.props.user.id]) {
|
|
||||||
requestedUsers[e.instance.props.user.id] = true;
|
|
||||||
queuedInstances[e.instance.props.user.id] = [].concat(queuedInstances[e.instance.props.user.id]).filter(n => n);
|
|
||||||
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id);
|
|
||||||
}
|
|
||||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "BioSection"});
|
|
||||||
if (index > -1) children.splice(this.settings.general.placeAtTop ? 1 : children.length - 2, 0, BDFDB.ReactUtils.createElement(class extends BDFDB.ReactUtils.Component {
|
|
||||||
render() {
|
render() {
|
||||||
if (!loadedUsers[e.instance.props.user.id]) {
|
if (!loadedUsers[this.props.user.id]) {
|
||||||
if (queuedInstances[e.instance.props.user.id].indexOf(this) == -1) queuedInstances[e.instance.props.user.id].push(this);
|
if (queuedInstances[this.props.user.id].indexOf(this) == -1) queuedInstances[this.props.user.id].push(this);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let connections = loadedUsers[e.instance.props.user.id].filter(c => _this.settings.connections[c.type]);
|
let connections = loadedUsers[this.props.user.id].filter(c => _this.settings.connections[c.type]);
|
||||||
if (!connections.length) return null;
|
if (!connections.length) return null;
|
||||||
let isLightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
let isLightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserPopoutSection, {
|
let children = [
|
||||||
children: [
|
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Heading, {
|
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Heading, {
|
||||||
className: BDFDB.disCN.userpopoutsectiontitle,
|
className: BDFDB.disCN.userpopoutsectiontitle,
|
||||||
variant: "eyebrow",
|
variant: "eyebrow",
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.CONNECTIONS
|
color: this.props.old ? "header-secondary" : null,
|
||||||
}),
|
|
||||||
BDFDB.ReactUtils.createElement("div", {
|
|
||||||
className: BDFDB.disCN._showconnectionsconnections,
|
|
||||||
children: connections.map(c => {
|
|
||||||
let provider = BDFDB.LibraryModules.ConnectionProviderUtils.get(c.type);
|
|
||||||
let url = _this.settings.general.openWebpage && provider.getPlatformUserUrl && provider.getPlatformUserUrl(c);
|
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
|
||||||
text: `${provider.name}: ${c.name}`,
|
|
||||||
tooltipConfig: {backgroundColor: _this.settings.general.useColoredTooltips && BDFDB.ColorUtils.change(provider.color, -0.3), color: !_this.settings.general.useColoredTooltips || !provider.color ? "black" : null},
|
|
||||||
children: BDFDB.ReactUtils.createElement(!url ? "div" : BDFDB.LibraryComponents.Anchor, Object.assign(!url ? {} : {
|
|
||||||
href: url
|
|
||||||
}, {
|
|
||||||
className: BDFDB.DOMUtils.formatClassName(BDFDB.disCN._showconnectionsconnection, url && BDFDB.disCN.cursorpointer),
|
|
||||||
onContextMenu: event => {
|
|
||||||
BDFDB.ContextMenuUtils.open(_this, event, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
|
||||||
children: [
|
|
||||||
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
|
||||||
label: BDFDB.LanguageUtils.LibraryStringsFormat("copy", BDFDB.LanguageUtils.LanguageStrings.USER_SETTINGS_LABEL_USERNAME),
|
|
||||||
id: BDFDB.ContextMenuUtils.createItemId(_this.name, "copy-name"),
|
|
||||||
action: _ => BDFDB.LibraryModules.WindowUtils.copy(c.name)
|
|
||||||
}),
|
|
||||||
url && BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
|
||||||
label: BDFDB.LanguageUtils.LibraryStringsFormat("copy", BDFDB.LanguageUtils.LanguageStrings.SEARCH_ANSWER_HAS_LINK),
|
|
||||||
id: BDFDB.ContextMenuUtils.createItemId(_this.name, "copy-url"),
|
|
||||||
action: _ => BDFDB.LibraryModules.WindowUtils.copy(url)
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
children: [
|
|
||||||
BDFDB.ReactUtils.createElement("img", {
|
|
||||||
className: BDFDB.disCN._showconnectionsicon,
|
|
||||||
alt: BDFDB.LanguageUtils.LanguageStringsFormat("IMG_ALT_LOGO", provider.name),
|
|
||||||
src: provider.icon[_this.settings.general.useColoredIcons ? (isLightTheme ? "lightSVG" : "darkSVG" ) : "whiteSVG"]
|
|
||||||
}),
|
|
||||||
_this.settings.general.showVerifiedBadge && c.verified && BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.TooltipContainer, {
|
|
||||||
text: BDFDB.LanguageUtils.LanguageStrings.CONNECTION_VERIFIED,
|
|
||||||
tooltipConfig: {color: "brand", type: "bottom"},
|
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.FlowerStar, {
|
|
||||||
className: BDFDB.disCN._showconnectionsverifiedbadge,
|
|
||||||
size: "50%",
|
|
||||||
color: isLightTheme ? BDFDB.DiscordConstants.Colors.STATUS_GREY_200 : BDFDB.DiscordConstants.Colors.PRIMARY_DARK,
|
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SvgIcon, {
|
|
||||||
name: BDFDB.LibraryComponents.SvgIcon.Names.CHECKMARK,
|
|
||||||
width: "70%",
|
|
||||||
height: "70%",
|
|
||||||
color: isLightTheme ? BDFDB.DiscordConstants.Colors.STATUS_GREY_500 : BDFDB.DiscordConstants.Colors.WHITE
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
})
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
processUserPopoutBody (e) {
|
|
||||||
if (!e.instance.props.user || e.instance.props.user.isNonUserBot()) return;
|
|
||||||
if (!loadedUsers[e.instance.props.user.id] && !requestedUsers[e.instance.props.user.id]) {
|
|
||||||
requestedUsers[e.instance.props.user.id] = true;
|
|
||||||
queuedInstances[e.instance.props.user.id] = [].concat(queuedInstances[e.instance.props.user.id]).filter(n => n);
|
|
||||||
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id);
|
|
||||||
}
|
|
||||||
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(class extends BDFDB.ReactUtils.Component {
|
|
||||||
render() {
|
|
||||||
if (!loadedUsers[e.instance.props.user.id]) {
|
|
||||||
if (queuedInstances[e.instance.props.user.id].indexOf(this) == -1) queuedInstances[e.instance.props.user.id].push(this);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let connections = loadedUsers[e.instance.props.user.id].filter(c => _this.settings.connections[c.type]);
|
|
||||||
if (!connections.length) return null;
|
|
||||||
let isLightTheme = BDFDB.DiscordUtils.getTheme() == BDFDB.disCN.themelight;
|
|
||||||
return [
|
|
||||||
BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.Heading, {
|
|
||||||
className: BDFDB.disCN.userpopoutbodytitle,
|
|
||||||
variant: "eyebrow",
|
|
||||||
color: "header-secondary",
|
|
||||||
children: BDFDB.LanguageUtils.LanguageStrings.CONNECTIONS
|
children: BDFDB.LanguageUtils.LanguageStrings.CONNECTIONS
|
||||||
}),
|
}),
|
||||||
BDFDB.ReactUtils.createElement("div", {
|
BDFDB.ReactUtils.createElement("div", {
|
||||||
|
@ -330,8 +131,138 @@ module.exports = (_ => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
return this.props.old ? children : BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserPopoutSection, {
|
||||||
|
children: children
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return class ShowConnections extends Plugin {
|
||||||
|
onLoad () {
|
||||||
|
_this = this;
|
||||||
|
loadedUsers = {};
|
||||||
|
requestedUsers = {};
|
||||||
|
queuedInstances = {};
|
||||||
|
|
||||||
|
this.modulePatches = {
|
||||||
|
after: [
|
||||||
|
"UserPopoutBody",
|
||||||
|
"UserThemedPopoutBody"
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
this.defaults = {
|
||||||
|
general: {
|
||||||
|
useColoredIcons: {value: true, description: "Uses colored Version of the Icons"},
|
||||||
|
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"},
|
||||||
|
openWebpage: {value: true, description: "Opens the Connection Page when clicking the Icon"}
|
||||||
|
},
|
||||||
|
connections: {}
|
||||||
|
};
|
||||||
|
|
||||||
|
for (let connection of BDFDB.LibraryModules.ConnectionProviderUtils.filter(n => n)) this.defaults.connections[connection.type] = Object.assign({}, connection, {value: true});
|
||||||
|
|
||||||
|
this.css = `
|
||||||
|
${BDFDB.dotCN._showconnectionsconnections} {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN._showconnectionsconnection} {
|
||||||
|
position: relative;
|
||||||
|
width: 28px;
|
||||||
|
height: 28px;
|
||||||
|
margin: 4px 10px 6px 0;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN._showconnectionsicon} {
|
||||||
|
margin: -15% 0 0 -15%;
|
||||||
|
width: 130%;
|
||||||
|
height: 130%;
|
||||||
|
}
|
||||||
|
${BDFDB.dotCN._showconnectionsverifiedbadge} {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -10%;
|
||||||
|
right: -10%;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
onStart () {
|
||||||
|
BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.DispatchApiUtils, "dispatch", {after: e => {
|
||||||
|
if (BDFDB.ObjectUtils.is(e.methodArguments[0]) && e.methodArguments[0].type == "USER_PROFILE_FETCH_SUCCESS" && e.methodArguments[0].user && e.methodArguments[0].connected_accounts) {
|
||||||
|
const user = e.methodArguments[0].user;
|
||||||
|
delete requestedUsers[user.id];
|
||||||
|
loadedUsers[user.id] = e.methodArguments[0].connected_accounts;
|
||||||
|
BDFDB.ReactUtils.forceUpdate(queuedInstances[user.id]);
|
||||||
|
delete queuedInstances[user.id];
|
||||||
|
}
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
|
||||||
|
onStop () {}
|
||||||
|
|
||||||
|
getSettingsPanel (collapseStates = {}) {
|
||||||
|
let settingsPanel;
|
||||||
|
return settingsPanel = BDFDB.PluginUtils.createSettingsPanel(this, {
|
||||||
|
collapseStates: collapseStates,
|
||||||
|
children: _ => {
|
||||||
|
let settingsItems = [];
|
||||||
|
|
||||||
|
for (let key in this.defaults.general) settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
|
type: "Switch",
|
||||||
|
plugin: this,
|
||||||
|
keys: ["general", key],
|
||||||
|
label: this.defaults.general[key].description,
|
||||||
|
value: this.settings.general[key]
|
||||||
|
}));
|
||||||
|
|
||||||
|
settingsItems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelList, {
|
||||||
|
title: "Display Connections:",
|
||||||
|
children: Object.keys(this.defaults.connections).map(key => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
|
type: "Switch",
|
||||||
|
plugin: this,
|
||||||
|
keys: ["connections", key],
|
||||||
|
label: this.defaults.connections[key].name,
|
||||||
|
value: this.settings.connections[key],
|
||||||
|
labelChildren: [
|
||||||
|
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.lightSVG}),
|
||||||
|
BDFDB.ReactUtils.createElement("img", {style: {width: 28, height: 28}, src: this.defaults.connections[key].icon.whiteSVG})
|
||||||
|
]
|
||||||
|
}))
|
||||||
|
}));
|
||||||
|
|
||||||
|
return settingsItems;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
processUserThemedPopoutBody (e) {
|
||||||
|
if (!e.instance.props.user || e.instance.props.user.isNonUserBot()) return;
|
||||||
|
if (!loadedUsers[e.instance.props.user.id] && !requestedUsers[e.instance.props.user.id]) {
|
||||||
|
requestedUsers[e.instance.props.user.id] = true;
|
||||||
|
queuedInstances[e.instance.props.user.id] = [].concat(queuedInstances[e.instance.props.user.id]).filter(n => n);
|
||||||
|
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id);
|
||||||
|
}
|
||||||
|
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "UserBioSection"});
|
||||||
|
if (index > -1) children.splice(this.settings.general.placeAtTop ? 1 : children.length - 2, 0, BDFDB.ReactUtils.createElement(UserConnectionsComponents, {
|
||||||
|
user: e.instance.props.user
|
||||||
|
}, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
processUserPopoutBody (e) {
|
||||||
|
if (!e.instance.props.user || e.instance.props.user.isNonUserBot()) return;
|
||||||
|
if (!loadedUsers[e.instance.props.user.id] && !requestedUsers[e.instance.props.user.id]) {
|
||||||
|
requestedUsers[e.instance.props.user.id] = true;
|
||||||
|
queuedInstances[e.instance.props.user.id] = [].concat(queuedInstances[e.instance.props.user.id]).filter(n => n);
|
||||||
|
BDFDB.LibraryModules.UserProfileUtils.fetchProfile(e.instance.props.user.id);
|
||||||
|
}
|
||||||
|
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, {
|
||||||
|
old: true,
|
||||||
|
user: e.instance.props.user
|
||||||
}, true));
|
}, true));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue