Fix file dialog opening when sending chat messages

master
Torjus 2018-07-30 11:29:37 +02:00
parent a90c287989
commit c908fa8855
4 changed files with 27 additions and 24 deletions

View File

@ -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
});
});
};

View File

@ -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
/>
<button onClick={this.handleClick}>share file</button>
<button
type='button'
onClick={this.handleClick}
>
share file
</button>
</div>
);
}

View File

@ -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);

View File

@ -43,6 +43,4 @@ export const store = createStore(
reducers,
undefined,
enhancer
);
console.log(store);
);