mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-16 09:57:08 -04:00
FullSearchContext: Re-add Copy Author ID
This commit is contained in:
parent
409f47bf24
commit
9239afdab9
2 changed files with 31 additions and 9 deletions
|
@ -16,15 +16,16 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { findGroupChildrenByChildId, NavContextMenuPatchCallback } from "@api/ContextMenu";
|
||||
import { migratePluginSettings } from "@api/Settings";
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
import { findByPropsLazy } from "@webpack";
|
||||
import { ChannelStore, ContextMenuApi, i18n, UserStore } from "@webpack/common";
|
||||
import { findByPropsLazy, findComponentByCodeLazy } from "@webpack";
|
||||
import { ChannelStore, Clipboard, ContextMenuApi, i18n, Menu, UserStore } from "@webpack/common";
|
||||
import { Message } from "discord-types/general";
|
||||
import type { MouseEvent } from "react";
|
||||
|
||||
const { useMessageMenu } = findByPropsLazy("useMessageMenu");
|
||||
const IdIcon = findComponentByCodeLazy("M15.3 14.48c-.46.45-1.08.67-1.86.67h");
|
||||
|
||||
function MessageMenu({ message, channel, onHeightUpdate }) {
|
||||
const canReport = message.author &&
|
||||
|
@ -48,9 +49,25 @@ function MessageMenu({ message, channel, onHeightUpdate }) {
|
|||
itemSrc: void 0,
|
||||
itemSafeSrc: void 0,
|
||||
itemTextContent: void 0,
|
||||
|
||||
isFullSearchContextMenu: true
|
||||
});
|
||||
}
|
||||
|
||||
const contextMenuPatch: NavContextMenuPatchCallback = (children, props) => {
|
||||
if (props?.isFullSearchContextMenu == null) return;
|
||||
|
||||
const group = findGroupChildrenByChildId("devmode-copy-id", children, true);
|
||||
group?.push(
|
||||
<Menu.MenuItem
|
||||
id={`devmode-copy-id-${props.message.author.id}`}
|
||||
label={i18n.Messages.COPY_ID_AUTHOR}
|
||||
action={() => Clipboard.copy(props.message.author.id)}
|
||||
icon={IdIcon}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
migratePluginSettings("FullSearchContext", "SearchReply");
|
||||
export default definePlugin({
|
||||
name: "FullSearchContext",
|
||||
|
@ -65,7 +82,7 @@ export default definePlugin({
|
|||
}
|
||||
}],
|
||||
|
||||
handleContextMenu(event: MouseEvent, message: Message) {
|
||||
handleContextMenu(event: React.MouseEvent, message: Message) {
|
||||
const channel = ChannelStore.getChannel(message.channel_id);
|
||||
if (!channel) return;
|
||||
|
||||
|
@ -78,5 +95,9 @@ export default definePlugin({
|
|||
onHeightUpdate={contextMenuProps.onHeightUpdate}
|
||||
/>
|
||||
);
|
||||
},
|
||||
|
||||
contextMenus: {
|
||||
"message-actions": contextMenuPatch
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue