MAR v2.0.3

This commit is contained in:
_Lighty_ 2019-12-31 15:31:08 +01:00
parent 43744f8d99
commit 9bcfcfb2ee
2 changed files with 148 additions and 146 deletions

View File

@ -1,4 +1,9 @@
# [MentionAliasesRedux](https://1lighty.github.io/BetterDiscordStuff/?plugin=MentionAliasesRedux "MentionAliasesRedux") Changelog
### 2.0.3
- Fixed clicking items in the menu not working
- Fixed tagging groups not working well
- Fixed unfriendly patch
### 2.0.2
- Plugin has been renamed to MentionAliasesRedux to avoid issues loading due to the original plugin, as well as to be able to distinguish between the two more easily.
- Fixed plugin description being wrong

View File

@ -41,21 +41,16 @@ var MentionAliasesRedux = (() => {
twitter_username: ''
}
],
version: '2.0.2',
version: '2.0.3',
description: 'Set custom @mention aliases, that can also appear next to their name (nearly) anywhere, as well as have mention groups to mention multiple people at once.',
github: 'https://github.com/1Lighty',
github_raw: 'https://raw.githubusercontent.com/1Lighty/BetterDiscordPlugins/master/Plugins/MentionAliasesRedux/MentionAliasesRedux.plugin.js'
},
changelog: [
{
title: 'plugin has been renamed!',
type: 'added',
items: ['Plugin has been renamed to MentionAliasesRedux to avoid issues loading due to the original plugin, as well as to be able to distinguish between the two more easily.']
},
{
title: 'fixed',
type: 'fixed',
items: ['Fixed plugin description being wrong', 'Fixed menu button not showing']
items: ['Fixed clicking items in the menu not working', 'Fixed tagging groups not working well', 'Fixed unfriendly patch']
}
],
defaultConfig: [
@ -156,7 +151,7 @@ var MentionAliasesRedux = (() => {
/* Build */
const buildPlugin = ([Plugin, Api]) => {
const { ContextMenu, EmulatedTooltip, Toasts, Settings, Popouts, Modals, Utilities, WebpackModules, Filters, DiscordModules, ColorConverter, DOMTools, DiscordClasses, DiscordSelectors, ReactTools, ReactComponents, DiscordAPI, Logger, Patcher, PluginUpdater, PluginUtilities, DiscordClassModules, Structs } = Api;
const { React, ModalStack, ContextMenuActions, ContextMenuItem, ContextMenuItemsGroup, ReactDOM, ChannelStore, GuildStore, UserStore, DiscordConstants, Dispatcher, GuildMemberStore, GuildActions, SwitchRow, EmojiUtils, RadioGroup, Permissions, TextElement, FlexChild, PopoutOpener, Textbox } = DiscordModules;
const { React, ModalStack, ContextMenuActions, ContextMenuItem, ContextMenuItemsGroup, ReactDOM, ChannelStore, GuildStore, UserStore, DiscordConstants, Dispatcher, GuildMemberStore, GuildActions, SwitchRow, EmojiUtils, RadioGroup, Permissions, TextElement, FlexChild, PopoutOpener, Textbox, UserSettingsStore } = DiscordModules;
const UserStatusStore = WebpackModules.getByProps('getStatus');
@ -309,7 +304,8 @@ var MentionAliasesRedux = (() => {
}
handleClick(text, rich) {
if (!this.props.channelTextAreaRef._editorRef) return Toasts.error('Internal error, cannot get _editorRef');
this.props.channelTextAreaRef._editorRef.appendText(text);
/* hm.. */
this.props.channelTextAreaRef._editorRef.ref.current.insertText(/* UserSettingsStore.useRichChatTextBox ? rich : */ text, true);
}
handleMentionsChange() {
this.setState({ mentions: this.props.getMentions() });
@ -350,12 +346,12 @@ var MentionAliasesRedux = (() => {
const children = [];
try {
this.state.mentions.users.forEach(({ userId, alias }, index) => {
if (!index) children.push(this.renderHeader(`Users—${this.state.mentions.users.length}`));
if (!index) children.push(this.renderHeader(`Users—${this.state.mentions.users.length}`));
const user = UserStore.getUser(userId);
children.push(React.createElement(AliasItem, { isUser: true, onContextMenu: e => this.handleContextMenu(e, userId), onClick: () => this.handleClick(`@${user.tag}`, `<@${userId}>`) }, React.createElement('div', { className: AvatarWrapperClassname }, renderAvatar(user)), renderAlias(alias, user.tag, undefined, true)));
});
this.state.mentions.groups.forEach((group, index) => {
if (!index) children.push(this.renderHeader(`Groups—${this.state.mentions.groups.length}`, true));
if (!index) children.push(this.renderHeader(`Groups—${this.state.mentions.groups.length}`, true));
const groupUsers = this.props.getGroupUsers(group.users);
if (groupUsers.note.length > 32) groupUsers.note = groupUsers.note.substr(0, 32 - 3) + '...';
children.push(React.createElement(AliasItem, { onContextMenu: e => this.handleContextMenu(e, group.id, true), onClick: () => this.handleClick(groupUsers.tags, groupUsers.tagsIds) }, renderAlias(group.name, groupUsers.note, undefined, false)));
@ -877,15 +873,14 @@ var MentionAliasesRedux = (() => {
async patchChannelTextArea(promiseState) {
const ChannelTextArea = await ReactComponents.getComponentByName('ChannelTextAreaForm', `.${XenoLib.getSingleClass('channelTextArea')}`);
if (promiseState.cancelled) return;
Patcher.after(
WebpackModules.find(m => m.render && m.render.displayName === 'ChannelTextAreaContainer'),
'render',
(_this, _, ret) => {
const props = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children.2.props');
if (!props || props.disabled || !this.settings.display.displayButton) return;
const ChannelTextAreaContainer = WebpackModules.find(m => m.render && m.render.displayName === 'ChannelTextAreaContainer');
const original = ChannelTextAreaContainer.render;
Patcher.after(ChannelTextAreaContainer, 'render', (_this, _, ret) => {
const ChannelEditorContainer = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.1');
if (!ChannelEditorContainer || ChannelEditorContainer.props.disabled || !this.settings.display.displayButton) return;
const buttons = Utilities.getNestedProp(ret, 'props.children.0.props.children.props.children.2.props.children');
if (!buttons) return;
const _editorRef = Utilities.getNestedProp(props, 'editorRef.current');
const _editorRef = Utilities.getNestedProp(ChannelEditorContainer, 'ref.current');
buttons.unshift(
React.createElement(ChannelTextAreaButton, {
iconName: 'Nova_At',
@ -894,8 +889,9 @@ var MentionAliasesRedux = (() => {
onClick: e => this.openAliasesPopout(e, { _editorRef })
})
);
}
);
});
/* transfer displayName and such, to be friendly to other plugins */
Object.keys(original).forEach(name => (ChannelTextAreaContainer.render[name] = original[name]));
this.patchedModules.push(ChannelTextArea);
ChannelTextArea.forceUpdateAll();
}
@ -998,11 +994,12 @@ var MentionAliasesRedux = (() => {
Patcher.instead(WebpackModules.getByPrototypes('selectAutocompletion').prototype, 'selectAutocompletion', (_this, args, orig) => {
const selected = args[0];
const type = _this.state.autocompleteType;
if (type !== 'MENTIONS' || !_this._editorRef) return orig(...args);
const autocompletes = _this.props.autocompletes;
const _editorRef = _this.props.editorRef.current;
if (type !== 'MENTIONS' || !_editorRef) return orig(...args);
const autocompletes = _this.state.autocompletes;
const role = autocompletes.roles[selected - autocompletes.users.length - autocompletes.globals.length];
if (!role || !role.MA) return orig(...args);
_this._editorRef.insertAutocomplete(role.mentioned_users, role.mentioned_users_ids);
_editorRef.insertAutocomplete(role.mentioned_users, role.mentioned_users_ids);
});
}