Proper handling of moderator clearing files and sharing same file twice. Fixes #257

auto_join_3.3
Håvar Aambø Fosstveit 2020-04-30 23:06:02 +02:00
parent de413fb670
commit 3de8555c10
2 changed files with 31 additions and 6 deletions

View File

@ -674,7 +674,7 @@ export default class RoomClient
{
if (err)
{
return store.dispatch(requestActions.notify(
store.dispatch(requestActions.notify(
{
type : 'error',
text : intl.formatMessage({
@ -682,6 +682,8 @@ export default class RoomClient
defaultMessage : 'Unable to save file'
})
}));
return;
}
saveAs(blob, file.name);
@ -698,7 +700,9 @@ export default class RoomClient
if (existingTorrent)
{
// Never add duplicate torrents, use the existing one instead.
return this._handleTorrent(existingTorrent);
this._handleTorrent(existingTorrent);
return;
}
this._webTorrent.add(magnetUri, this._handleTorrent);
@ -710,11 +714,13 @@ export default class RoomClient
// same file was sent multiple times.
if (torrent.progress === 1)
{
return store.dispatch(
store.dispatch(
fileActions.setFileDone(
torrent.magnetURI,
torrent.files
));
return;
}
let lastMove = 0;
@ -757,7 +763,7 @@ export default class RoomClient
{
if (err)
{
return store.dispatch(requestActions.notify(
store.dispatch(requestActions.notify(
{
type : 'error',
text : intl.formatMessage({
@ -765,13 +771,30 @@ export default class RoomClient
defaultMessage : 'Unable to share file'
})
}));
return;
}
const existingTorrent = this._webTorrent.get(torrent);
if (existingTorrent)
{
return this._sendFile(existingTorrent.magnetURI);
store.dispatch(requestActions.notify(
{
text : intl.formatMessage({
id : 'filesharing.successfulFileShare',
defaultMessage : 'File successfully shared'
})
}));
store.dispatch(fileActions.addFile(
this._peerId,
existingTorrent.magnetURI
));
this._sendFile(existingTorrent.magnetURI);
return;
}
this._webTorrent.seed(

View File

@ -36,7 +36,7 @@ const FileSharing = (props) =>
{
if (event.target.files.length > 0)
{
props.roomClient.shareFiles(event.target.files);
await props.roomClient.shareFiles(event.target.files);
}
};
@ -65,6 +65,8 @@ const FileSharing = (props) =>
type='file'
disabled={!canShare}
onChange={handleFileChange}
// Need to reset to be able to share same file twice
onClick={(e) => (e.target.value = null)}
id='share-files-button'
/>
<label htmlFor='share-files-button'>