This commit is contained in:
Mirco Wittrien 2022-11-06 13:55:04 +01:00
parent 36fa5177b1
commit 05671871db
2 changed files with 14 additions and 51 deletions

View File

@ -2,7 +2,7 @@
* @name ClickableMentions
* @author DevilBro
* @authorId 278543574059057154
* @version 1.0.5
* @version 1.0.6
* @description Allows you to open a User Popout by clicking a Mention in your Message Input
* @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien
@ -58,15 +58,10 @@ module.exports = (_ => {
} : (([Plugin, BDFDB]) => {
return class ClickableMentions extends Plugin {
onLoad () {
this.patchedModules = {
before: {
RoleMention: "default"
},
after: {
RichUserMention: "UserMention",
RichRoleMention: "RoleMention",
RoleMention: "default"
}
this.modulePatches = {
after: [
"RichUserMention"
]
};
this.patchPriority = 9;
@ -81,48 +76,15 @@ module.exports = (_ => {
}
processRichUserMention (e) {
if (e.instance.props.id && BDFDB.LibraryStores.UserStore.getUser(e.instance.props.id)) return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserMention, {
className: "mention",
if (!e.instance.props.id || !BDFDB.LibraryStores.UserStore.getUser(e.instance.props.id) || typeof e.returnvalue.props.children != "function") return;
let childrenRender = e.returnvalue.props.children;
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.UserPopoutContainer, Object.assign({}, e.instance.props, {
killEvent: true,
userId: e.instance.props.id,
channelId: e.instance.props.channelId,
guildId: e.instance.props.guildId,
inlinePreview: false
});
}
processRichRoleMention (e) {
if (e.instance.props.id && e.instance.props.guildId && e.instance.props.id != e.instance.props.guildId) {
let guild = BDFDB.LibraryStores.GuildStore.getGuild(e.instance.props.guildId);
let channelId = e.instance.props.channelId;
if (!channelId) {
let currentChannelId = BDFDB.LibraryStores.SelectedChannelStore.getChannelId();
channelId = BDFDB.LibraryStores.GuildChannelStore.getSelectableChannelIds(guild.id).indexOf(currentChannelId) > -1 ? currentChannelId : BDFDB.LibraryStores.GuildChannelStore.getDefaultChannel(guild.id).id;
}
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.RoleMention, {
type: "mention_textarea",
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
});
}
}
processRoleMention (e) {
if (!e.returnvalue) {
if (e.instance.props.type == "mention_textarea") {
e.instance.props.type = "mention";
e.instance.props.place = "textarea";
}
}
else if (e.instance.props.place == "textarea") {
e.returnvalue.props.align = BDFDB.LibraryComponents.PopoutContainer.Align.BOTTOM;
}
position: BDFDB.LibraryComponents.PopoutContainer.Positions.RIGHT,
align: BDFDB.LibraryComponents.PopoutContainer.Align.BOTTOM,
children: childrenRender(...args)
})), "Error in Children Render of RichUserMention", this);
}
};
})(window.BDFDB_Global.PluginUtils.buildPlugin(changeLog));

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="black" d="M 0,1.091 V 4.3636999 H 6.5454546 V 22.909 H 9.818182 V 4.3636999 h 6.545455 V 1.091 Z M 12,8.7272994 V 12 h 4.363637 v 10.909 h 3.272726 V 12 H 24 V 8.7272994 Z"/></svg>

After

Width:  |  Height:  |  Size: 275 B