From 14fc2d9b2542f1953aae5c23e4397747b0293aaf Mon Sep 17 00:00:00 2001 From: Wolfie <32025746+Wolfkid200444@users.noreply.github.com> Date: Sun, 10 Mar 2024 08:17:49 -0400 Subject: [PATCH] Add Clipboard import and update ContextMenuApi.openContextMenu --- .../components/modals/RenderMessage.tsx | 93 +++++++++++++------ 1 file changed, 64 insertions(+), 29 deletions(-) diff --git a/src/plugins/holynotes/components/modals/RenderMessage.tsx b/src/plugins/holynotes/components/modals/RenderMessage.tsx index 92757a68b..495efe6dc 100644 --- a/src/plugins/holynotes/components/modals/RenderMessage.tsx +++ b/src/plugins/holynotes/components/modals/RenderMessage.tsx @@ -7,7 +7,7 @@ import { classes } from "@utils/misc"; import { ModalProps } from "@utils/modal"; import { findByCode, findByProps } from "@webpack"; -import { ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common"; +import { Clipboard, ContextMenuApi, FluxDispatcher, Menu, NavigationRouter, React } from "@webpack/common"; import noteHandler from "plugins/holynotes/noteHandler"; import { HolyNotes } from "plugins/holynotes/types"; @@ -64,7 +64,7 @@ export const RenderMessage = ({ onContextMenu={(event: any) => { if (!fromDeleteModal) // @ts-ignore - return open(event, (props: any) => ( + return ContextMenuApi.openContextMenu(event, (props: any) => ( // @ts-ignore embed.timestamp ? Object.assign(embed, { - // @ts-ignore - timestamp: new Moment(new Date(embed.timestamp)), + timestamp: new Date(embed.timestamp), }) : embed, ), @@ -122,31 +122,66 @@ const NoteContextMenu = ( const { note, notebook, updateParent, closeModal } = props; return ( -
{ - ContextMenuApi.openContextMenu(e, () => - FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })} - aria-label="Holy Notes" + FluxDispatcher.dispatch({ type: "CONTEXT_MENU_CLOSE" })} + aria-label="Holy Notes" + > + { + NavigationRouter.transitionTo(`/channels/${note.guild_id ?? "@me"}/${note.channel_id}/${note.id}`); + closeModal?.(); + }} + /> + Clipboard.copy(note.content)} + /> + {note?.attachments.length ? ( + Clipboard.copy(note.attachments[0].url)} + />) : null} + { + noteHandler.deleteNote(note.id, notebook); + updateParent?.(); + }} + /> + {Object.keys(noteHandler.getAllNotes()).length !== 1 ? ( + - { - NavigationRouter.transitionTo(`/channels/${note.guild_id ?? "@me"}/${note.channel_id}/${note.id}`); - closeModal?.(); - }} - /> - { - noteHandler.deleteNote(note.id, notebook); - updateParent?.(); - }} - /> - - ); - }}>
+ {Object.keys(noteHandler.getAllNotes()).map((key: string) => { + if (key !== notebook) { + return ( + { + noteHandler.moveNote(note, notebook, key); + updateParent?.(); + }} + /> + ); + } + })} + + ) : null} + Clipboard.copy(note.id)} + /> + ); + };