From c908fa8855429c2cd6c03707c54b89806bfbfe3a Mon Sep 17 00:00:00 2001 From: Torjus Date: Mon, 30 Jul 2018 11:29:37 +0200 Subject: [PATCH] Fix file dialog opening when sending chat messages --- app/lib/components/Chat/FileChatEntry.jsx | 12 ++++----- app/lib/components/Chat/FileSharing.jsx | 33 +++++++++++++---------- app/lib/redux/reducers/chatmessages.js | 2 +- app/lib/store.js | 4 +-- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/app/lib/components/Chat/FileChatEntry.jsx b/app/lib/components/Chat/FileChatEntry.jsx index b0712ac..faced6f 100644 --- a/app/lib/components/Chat/FileChatEntry.jsx +++ b/app/lib/components/Chat/FileChatEntry.jsx @@ -35,10 +35,10 @@ class FileChatEntry extends Component if (torrent.progress === 1) { this.setState({ - files: torrent.files, - numPeers: torrent.numPeers, - progress: 1, - active: false + files : torrent.files, + numPeers : torrent.numPeers, + progress : 1, + active : false }); return; @@ -62,8 +62,8 @@ class FileChatEntry extends Component clearInterval(onProgress); this.setState({ - files : torrent.files, - active: false + files : torrent.files, + active : false }); }); }; diff --git a/app/lib/components/Chat/FileSharing.jsx b/app/lib/components/Chat/FileSharing.jsx index fe801a2..c09fef8 100644 --- a/app/lib/components/Chat/FileSharing.jsx +++ b/app/lib/components/Chat/FileSharing.jsx @@ -9,9 +9,9 @@ import { store } from '../../store'; import config from '../../../config'; export const client = new WebTorrent({ - tracker: { - rtcConfig: { - iceServers: config.turnServers + tracker : { + rtcConfig : { + iceServers : config.turnServers } } }); @@ -24,13 +24,13 @@ const notifyPeers = (file) => store.dispatch(requestActions.sendChatFile(file, displayName, picture)); }; -const shareFiles = async (files) => +const shareFiles = async(files) => { const notification = { - id: randomString({ length: 6 }).toLowerCase(), - text: 'Creating torrent', - type: 'info' + id : randomString({ length: 6 }).toLowerCase(), + text : 'Creating torrent', + type : 'info' }; store.dispatch(stateActions.addNotification(notification)); @@ -40,7 +40,7 @@ const shareFiles = async (files) => if (err) { return store.dispatch(requestActions.notify({ - text: 'An error occured while uploading a file' + text : 'An error occured while uploading a file' })); } @@ -49,7 +49,7 @@ const shareFiles = async (files) => if (existingTorrent) { return notifyPeers({ - magnet: existingTorrent.magnetURI + magnet : existingTorrent.magnetURI }); } @@ -58,8 +58,8 @@ const shareFiles = async (files) => store.dispatch(stateActions.removeNotification(notification.id)); store.dispatch(requestActions.notify({ - text: 'Torrent successfully created' - })) + text : 'Torrent successfully created' + })); notifyPeers({ magnet : newTorrent.magnetURI @@ -68,7 +68,7 @@ const shareFiles = async (files) => }); }; -dragDrop('body', async (files) => await shareFiles(files)); +dragDrop('body', async(files) => await shareFiles(files)); class FileSharing extends Component { @@ -79,7 +79,7 @@ class FileSharing extends Component this.fileInput = React.createRef(); } - handleFileChange = async (event) => + handleFileChange = async(event) => { if (event.target.files.length > 0) { @@ -106,7 +106,12 @@ class FileSharing extends Component multiple /> - + ); } diff --git a/app/lib/redux/reducers/chatmessages.js b/app/lib/redux/reducers/chatmessages.js index baf8761..923f81c 100644 --- a/app/lib/redux/reducers/chatmessages.js +++ b/app/lib/redux/reducers/chatmessages.js @@ -19,7 +19,7 @@ const chatmessages = (state = [], action) => case 'ADD_NEW_USER_FILE': { - const { file } = action.payload; + const { file } = action.payload; const message = createNewFile(file, 'client', 'Me', undefined); diff --git a/app/lib/store.js b/app/lib/store.js index d4ee190..cdff97d 100644 --- a/app/lib/store.js +++ b/app/lib/store.js @@ -43,6 +43,4 @@ export const store = createStore( reducers, undefined, enhancer -); - -console.log(store); \ No newline at end of file +); \ No newline at end of file