Fix file dialog opening when sending chat messages
parent
a90c287989
commit
c908fa8855
|
|
@ -35,10 +35,10 @@ class FileChatEntry extends Component
|
||||||
if (torrent.progress === 1)
|
if (torrent.progress === 1)
|
||||||
{
|
{
|
||||||
this.setState({
|
this.setState({
|
||||||
files: torrent.files,
|
files : torrent.files,
|
||||||
numPeers: torrent.numPeers,
|
numPeers : torrent.numPeers,
|
||||||
progress: 1,
|
progress : 1,
|
||||||
active: false
|
active : false
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
@ -62,8 +62,8 @@ class FileChatEntry extends Component
|
||||||
clearInterval(onProgress);
|
clearInterval(onProgress);
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
files : torrent.files,
|
files : torrent.files,
|
||||||
active: false
|
active : false
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import { store } from '../../store';
|
||||||
import config from '../../../config';
|
import config from '../../../config';
|
||||||
|
|
||||||
export const client = new WebTorrent({
|
export const client = new WebTorrent({
|
||||||
tracker: {
|
tracker : {
|
||||||
rtcConfig: {
|
rtcConfig : {
|
||||||
iceServers: config.turnServers
|
iceServers : config.turnServers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -24,13 +24,13 @@ const notifyPeers = (file) =>
|
||||||
store.dispatch(requestActions.sendChatFile(file, displayName, picture));
|
store.dispatch(requestActions.sendChatFile(file, displayName, picture));
|
||||||
};
|
};
|
||||||
|
|
||||||
const shareFiles = async (files) =>
|
const shareFiles = async(files) =>
|
||||||
{
|
{
|
||||||
const notification =
|
const notification =
|
||||||
{
|
{
|
||||||
id: randomString({ length: 6 }).toLowerCase(),
|
id : randomString({ length: 6 }).toLowerCase(),
|
||||||
text: 'Creating torrent',
|
text : 'Creating torrent',
|
||||||
type: 'info'
|
type : 'info'
|
||||||
};
|
};
|
||||||
|
|
||||||
store.dispatch(stateActions.addNotification(notification));
|
store.dispatch(stateActions.addNotification(notification));
|
||||||
|
|
@ -40,7 +40,7 @@ const shareFiles = async (files) =>
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
return store.dispatch(requestActions.notify({
|
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)
|
if (existingTorrent)
|
||||||
{
|
{
|
||||||
return notifyPeers({
|
return notifyPeers({
|
||||||
magnet: existingTorrent.magnetURI
|
magnet : existingTorrent.magnetURI
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,8 +58,8 @@ const shareFiles = async (files) =>
|
||||||
store.dispatch(stateActions.removeNotification(notification.id));
|
store.dispatch(stateActions.removeNotification(notification.id));
|
||||||
|
|
||||||
store.dispatch(requestActions.notify({
|
store.dispatch(requestActions.notify({
|
||||||
text: 'Torrent successfully created'
|
text : 'Torrent successfully created'
|
||||||
}))
|
}));
|
||||||
|
|
||||||
notifyPeers({
|
notifyPeers({
|
||||||
magnet : newTorrent.magnetURI
|
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
|
class FileSharing extends Component
|
||||||
{
|
{
|
||||||
|
|
@ -79,7 +79,7 @@ class FileSharing extends Component
|
||||||
this.fileInput = React.createRef();
|
this.fileInput = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleFileChange = async (event) =>
|
handleFileChange = async(event) =>
|
||||||
{
|
{
|
||||||
if (event.target.files.length > 0)
|
if (event.target.files.length > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -106,7 +106,12 @@ class FileSharing extends Component
|
||||||
multiple
|
multiple
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<button onClick={this.handleClick}>share file</button>
|
<button
|
||||||
|
type='button'
|
||||||
|
onClick={this.handleClick}
|
||||||
|
>
|
||||||
|
share file
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ const chatmessages = (state = [], action) =>
|
||||||
|
|
||||||
case 'ADD_NEW_USER_FILE':
|
case 'ADD_NEW_USER_FILE':
|
||||||
{
|
{
|
||||||
const { file } = action.payload;
|
const { file } = action.payload;
|
||||||
|
|
||||||
const message = createNewFile(file, 'client', 'Me', undefined);
|
const message = createNewFile(file, 'client', 'Me', undefined);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,4 @@ export const store = createStore(
|
||||||
reducers,
|
reducers,
|
||||||
undefined,
|
undefined,
|
||||||
enhancer
|
enhancer
|
||||||
);
|
);
|
||||||
|
|
||||||
console.log(store);
|
|
||||||
Loading…
Reference in New Issue