diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index e8d5d39..d574d86 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -58,9 +58,11 @@ function RoomViewInput({ useEffect(() => { settings.on(cons.events.settings.MARKDOWN_TOGGLED, setIsMarkdown); + roomsInput.on(cons.events.roomsInput.ATTACHMENT_SET, setAttachment); viewEvent.on('focus_msg_input', requestFocusInput); return () => { settings.removeListener(cons.events.settings.MARKDOWN_TOGGLED, setIsMarkdown); + roomsInput.removeListener(cons.events.roomsInput.ATTACHMENT_SET, setAttachment); viewEvent.removeListener('focus_msg_input', requestFocusInput); }; }, []); diff --git a/src/app/templates/client/Client.jsx b/src/app/templates/client/Client.jsx index 6130a18..6768cc4 100644 --- a/src/app/templates/client/Client.jsx +++ b/src/app/templates/client/Client.jsx @@ -12,6 +12,8 @@ import EmojiBoardOpener from '../../organisms/emoji-board/EmojiBoardOpener'; import logout from '../../../client/action/logout'; import initMatrix from '../../../client/initMatrix'; +import navigation from '../../../client/state/navigation'; +import cons from '../../../client/state/cons'; function Client() { const [isLoading, changeLoading] = useState(true); @@ -54,8 +56,34 @@ function Client() { ); } + + const handleDrag = (e) => { + e.preventDefault(); + + if (!navigation.selectedRoomId) { + e.dataTransfer.dropEffect = 'none'; + } + }; + + const handleDrop = (e) => { + e.preventDefault(); + + const roomId = navigation.selectedRoomId; + if (!roomId) return; + + const { files } = e.dataTransfer; + if (!files) return; + const file = files[0]; + initMatrix.roomsInput.setAttachment(roomId, file); + initMatrix.roomsInput.emit(cons.events.roomsInput.ATTACHMENT_SET, file); + }; + return ( -