This commit is contained in:
Mirco Wittrien 2022-09-09 15:33:12 +02:00
parent 7cec9df5e9
commit 1b9676eb57
2 changed files with 36 additions and 21 deletions

View File

@ -303,7 +303,9 @@
"ReactorsComponent": {"class": "messagereactionsmodalreactor"},
"RecentsHeader": {"strings": ["expanded", "CompactRecentsHeader"]},
"RichChannelMention": {"props": ["ChannelMention"]},
"RichRoleMention": {"props": ["RoleMention"]},
"RichUserMention": {"props": ["UserMention"]},
"RoleMention": {"strings": ["rolePopout", "RoleMention"]},
"RTCConnection": {"class": "voicedetails"},
"SearchBar": {"props": ["SearchIcon"], "path": "default.prototype"},
"SearchResults": {"class": "searchresultswrap"},
@ -315,7 +317,7 @@
"TypingUsers": {"class": "typing"},
"UnavailableGuildsButton": {"strings": ["className", ".default.guildsError"]},
"Upload": {"class": "uploadmodal"},
"UserMention": {"strings": ["inlinePreview", "getAvatarURL", "userId", "default.getName"]},
"UserMention": {"strings": [".inlinePreview", "renderPopout", ".openContextMenu", ".isMobile"]},
"UserPopoutAvatar": {"props": ["UserPopoutAvatar"]},
"UserPopoutBodySection": {"strings": [".customStatusActivity", ".canDM", ".hidePersonalInformation"]},
"UserProfileModal": {"lazyLoaded": true},
@ -411,6 +413,7 @@
"PopoutFocusLock": {"strings": ["useFocusLock", "useImperativeHandle"], "value": "default"},
"PrivateChannelItems": {"props": ["DirectMessage", "GroupDM"]},
"QuickSwitchItems": {"props": ["Channel", "GroupDM", "Header"]},
"RoleMention": {"strings": ["rolePopout", "RoleMention"], "value": "default"},
"Scrollers": {
"children": {
"Auto": {"props": ["AdvancedScrollerThin", "AdvancedScrollerAuto"], "value": "AdvancedScrollerAuto"},
@ -425,6 +428,7 @@
"TextElement": {"props": ["Colors", "Sizes"]},
"UserBadgeKeys": {"props": ["BadgeKeys"], "value": "BadgeKeys"},
"UserBadges": {"props": ["BadgeSizes"]},
"UserMention": {"strings": [".inlinePreview", "renderPopout", ".openContextMenu", ".isMobile"]},
"UserPopout": {"name": "UserPopoutContainer"},
"UserPopoutSection": {"name": "UserPopoutSection"},
"UserSummaryItem": {"name": "UserSummaryItem"},

View File

@ -2,7 +2,7 @@
* @name ClickableMentions
* @author DevilBro
* @authorId 278543574059057154
* @version 1.0.3
* @version 1.0.4
* @description Allows you to open a User Popout by clicking a Mention in your Message Input
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -60,7 +60,8 @@ module.exports = (_ => {
onLoad () {
this.patchedModules = {
after: {
RichUserMention: "UserMention"
RichUserMention: "UserMention",
RichRoleMention: "RoleMention"
}
};
@ -76,26 +77,36 @@ module.exports = (_ => {
}
processRichUserMention (e) {
if (e.instance.props.id && BDFDB.LibraryModules.UserStore.getUser(e.instance.props.id)) {
if (typeof e.returnvalue.props.children == "function") {
let childrenRender = e.returnvalue.props.children;
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => this.injectUserPopoutContainer(e.instance.props, childrenRender(...args)), "", this);
}
else e.returnvalue = this.injectUserPopoutContainer(e.instance.props, e.returnvalue.props.children);
}
if (e.instance.props.id && BDFDB.LibraryModules.UserStore.getUser(e.instance.props.id)) return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserMention, {
className: "mention",
userId: e.instance.props.id,
channelId: e.instance.props.channelId,
guildId: e.instance.props.guildId,
inlinePreview: false
});
}
injectUserPopoutContainer (props, children) {
children.props.className = BDFDB.DOMUtils.formatClassName(children.props.className, BDFDB.disCN.cursorpointer);
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserPopoutContainer, {
position: BDFDB.LibraryComponents.PopoutContainer.Positions.TOP,
align: BDFDB.LibraryComponents.PopoutContainer.Align.CENTER,
killEvent: true,
userId: props.id,
channelId: props.channel && props.channel.id || props.channelId,
guildId: props.channel && props.channel.guild_id || props.guildId,
children: children
});
processRichRoleMention (e) {
if (e.instance.props.id && e.instance.props.guildId && e.instance.props.id != e.instance.props.guildId) {
let guild = BDFDB.LibraryModules.GuildStore.getGuild(e.instance.props.guildId);
let channelId = e.instance.props.channelId;
if (!channelId) {
let currentChannelId = BDFDB.LibraryModules.LastChannelStore.getChannelId();
channelId = BDFDB.LibraryModules.GuildChannelStore.getSelectableChannelIds(guild.id).indexOf(currentChannelId) > -1 ? currentChannelId : BDFDB.LibraryModules.GuildChannelStore.getDefaultChannel(guild.id).id;
}
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.RoleMention, {
type: "mention",
children: [`@${guild.roles[e.instance.props.id].name}`],
content: [
{type: "text", content: `@${guild.roles[e.instance.props.id].name}`}
],
roleColor: guild.roles[e.instance.props.id].color,
roleId: e.instance.props.id,
channelId: channelId,
guildId: e.instance.props.guildId,
inlinePreview: false
});
}
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));