From 22801c1b915ebf37e10b9e818f375ef4f1edb271 Mon Sep 17 00:00:00 2001 From: C0ffeeCode Date: Sun, 2 Jan 2022 22:48:01 +0100 Subject: [PATCH] needs ui --- matrix-js-sdk | 1 - .../organisms/room/AttachmentTypeSelector.jsx | 5 +++- src/app/organisms/room/RoomViewInput.jsx | 26 ++++++++----------- 3 files changed, 15 insertions(+), 17 deletions(-) delete mode 160000 matrix-js-sdk diff --git a/matrix-js-sdk b/matrix-js-sdk deleted file mode 160000 index f30be878..00000000 --- a/matrix-js-sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f30be878793407b02fad1e85676d4c1644a7c30c diff --git a/src/app/organisms/room/AttachmentTypeSelector.jsx b/src/app/organisms/room/AttachmentTypeSelector.jsx index dd4ca3ad..e849fd97 100644 --- a/src/app/organisms/room/AttachmentTypeSelector.jsx +++ b/src/app/organisms/room/AttachmentTypeSelector.jsx @@ -2,12 +2,14 @@ import React from 'react'; import PropTypes from 'prop-types'; import IconButton from '../../atoms/button/IconButton'; import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg'; +import FileIC from '../../../../public/res/ic/outlined/file.svg'; import ContextMenu, { MenuHeader, MenuItem } from '../../atoms/context-menu/ContextMenu'; const AttachmentTypes = { remove: 'remove', file: 'file', voice: 'voice', + currentLocation: 'currentLocation', }; function AttachmentTypeSelector({ alreadyHasAttachment, actOnAttaching }) { @@ -21,6 +23,7 @@ function AttachmentTypeSelector({ alreadyHasAttachment, actOnAttaching }) { onClick={() => { toggleMenu(); actOnAttaching(AttachmentTypes.file); }} + iconSrc={FileIC} > File @@ -42,7 +45,7 @@ function AttachmentTypeSelector({ alreadyHasAttachment, actOnAttaching }) { actOnAttaching(AttachmentTypes.remove); } }} - tooltip={alreadyHasAttachment ? 'Upload' : 'Cancel'} + tooltip={alreadyHasAttachment ? 'Cancel' : 'Select attachment'} src={CirclePlusIC} /> )} diff --git a/src/app/organisms/room/RoomViewInput.jsx b/src/app/organisms/room/RoomViewInput.jsx index ea407f59..b6302535 100644 --- a/src/app/organisms/room/RoomViewInput.jsx +++ b/src/app/organisms/room/RoomViewInput.jsx @@ -8,7 +8,7 @@ import TextareaAutosize from 'react-autosize-textarea'; import initMatrix from '../../../client/initMatrix'; import cons from '../../../client/state/cons'; import settings from '../../../client/state/settings'; -import { openAttachmentTypeSelector, openEmojiBoard } from '../../../client/action/navigation'; +import { openEmojiBoard } from '../../../client/action/navigation'; import navigation from '../../../client/state/navigation'; import { bytesToSize, getEventCords } from '../../../util/common'; import { getUsername } from '../../../util/matrixUtil'; @@ -20,7 +20,6 @@ import IconButton from '../../atoms/button/IconButton'; import ScrollView from '../../atoms/scroll/ScrollView'; import { MessageReply } from '../../molecules/message/Message'; -import CirclePlusIC from '../../../../public/res/ic/outlined/circle-plus.svg'; import EmojiIC from '../../../../public/res/ic/outlined/emoji.svg'; import SendIC from '../../../../public/res/ic/outlined/send.svg'; import ShieldIC from '../../../../public/res/ic/outlined/shield.svg'; @@ -293,15 +292,15 @@ function RoomViewInput({ function uploadFileChange(e) { const file = e.target.files.item(0); setAttachment(file); - console.log(file); if (file !== null) roomsInput.setAttachment(roomId, file); } const recordVoice = () => { - navigator.getUserMedia = navigator.getUserMedia - || navigator.webkitGetUserMedia - || navigator.mozGetUserMedia - || navigator.msGetUserMedia; + // TODO: Check if supported + // navigator.getUserMedia = navigator.getUserMedia + // || navigator.webkitGetUserMedia + // || navigator.mozGetUserMedia + // || navigator.msGetUserMedia; navigator.mediaDevices.getUserMedia({ audio: true }) .then((stream) => { @@ -317,20 +316,17 @@ function RoomViewInput({ const opts = { type: 'audio/webm' }; const audioBlob = new Blob(audioChunks, opts); - audioBlob.text() - .then(() => { - const a = new File([audioBlob], 'voicemail.webm', opts); + const audioFile = new File([audioBlob], 'voicemail.webm', opts); - console.log(a); - roomsInput.setAttachment(roomId, a); - }); + setAttachment(audioFile); + roomsInput.setAttachment(roomId, audioFile); }); setTimeout(() => { mediaRecorder.stop(); }, 5000); // 1 hour 3600000 }) - .catch((e) => console.log(e)); + .catch(console.log); }; const handleAttachmentTypeSelectorReturn = (ret) => { @@ -364,7 +360,6 @@ function RoomViewInput({
@@ -407,6 +402,7 @@ function RoomViewInput({ function attachFile() { const fileType = attachment.type.slice(0, attachment.type.indexOf('/')); + console.log(attachment.type); return (