Handle it correctly if a user tries to share a file that has allready been shared. Closes #142
parent
160a510f8e
commit
197156e6f6
|
|
@ -11,9 +11,10 @@
|
||||||
"@material-ui/core": "^4.5.1",
|
"@material-ui/core": "^4.5.1",
|
||||||
"@material-ui/icons": "^4.5.1",
|
"@material-ui/icons": "^4.5.1",
|
||||||
"bowser": "^2.7.0",
|
"bowser": "^2.7.0",
|
||||||
|
"create-torrent": "^4.4.1",
|
||||||
"dompurify": "^2.0.7",
|
"dompurify": "^2.0.7",
|
||||||
"domready": "^1.0.8",
|
"domready": "^1.0.8",
|
||||||
"end-of-stream": "1.4.0",
|
"end-of-stream": "1.4.1",
|
||||||
"file-saver": "^2.0.2",
|
"file-saver": "^2.0.2",
|
||||||
"hark": "^1.2.3",
|
"hark": "^1.2.3",
|
||||||
"is-electron": "^2.2.0",
|
"is-electron": "^2.2.0",
|
||||||
|
|
@ -37,7 +38,7 @@
|
||||||
"riek": "^1.1.0",
|
"riek": "^1.1.0",
|
||||||
"socket.io-client": "^2.3.0",
|
"socket.io-client": "^2.3.0",
|
||||||
"source-map-explorer": "^2.1.0",
|
"source-map-explorer": "^2.1.0",
|
||||||
"webtorrent": "^0.107.16"
|
"webtorrent": "^0.107.17"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "source-map-explorer build/static/js/*",
|
"analyze": "source-map-explorer build/static/js/*",
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import * as consumerActions from './actions/consumerActions';
|
||||||
import * as producerActions from './actions/producerActions';
|
import * as producerActions from './actions/producerActions';
|
||||||
import * as notificationActions from './actions/notificationActions';
|
import * as notificationActions from './actions/notificationActions';
|
||||||
|
|
||||||
|
let createTorrent;
|
||||||
|
|
||||||
let WebTorrent;
|
let WebTorrent;
|
||||||
|
|
||||||
let saveAs;
|
let saveAs;
|
||||||
|
|
@ -756,26 +758,48 @@ export default class RoomClient
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._webTorrent.seed(
|
createTorrent(files, (err, torrent) =>
|
||||||
files,
|
{
|
||||||
{ announceList: [ [ 'wss://tracker.lab.vvc.niif.hu:443' ] ] },
|
if (err)
|
||||||
(torrent) =>
|
|
||||||
{
|
{
|
||||||
store.dispatch(requestActions.notify(
|
return store.dispatch(requestActions.notify(
|
||||||
{
|
{
|
||||||
|
type : 'error',
|
||||||
text : intl.formatMessage({
|
text : intl.formatMessage({
|
||||||
id : 'filesharing.successfulFileShare',
|
id : 'filesharing.unableToShare',
|
||||||
defaultMessage : 'File successfully shared'
|
defaultMessage : 'Unable to share file'
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
store.dispatch(fileActions.addFile(
|
const existingTorrent = this._webTorrent.get(torrent);
|
||||||
this._peerId,
|
|
||||||
torrent.magnetURI
|
|
||||||
));
|
|
||||||
|
|
||||||
this._sendFile(torrent.magnetURI);
|
if (existingTorrent)
|
||||||
});
|
{
|
||||||
|
return this._sendFile(existingTorrent.magnetURI);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._webTorrent.seed(
|
||||||
|
files,
|
||||||
|
{ announceList: [ [ 'wss://tracker.lab.vvc.niif.hu:443' ] ] },
|
||||||
|
(newTorrent) =>
|
||||||
|
{
|
||||||
|
store.dispatch(requestActions.notify(
|
||||||
|
{
|
||||||
|
text : intl.formatMessage({
|
||||||
|
id : 'filesharing.successfulFileShare',
|
||||||
|
defaultMessage : 'File successfully shared'
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
|
||||||
|
store.dispatch(fileActions.addFile(
|
||||||
|
this._peerId,
|
||||||
|
newTorrent.magnetURI
|
||||||
|
));
|
||||||
|
|
||||||
|
this._sendFile(newTorrent.magnetURI);
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// { file, name, picture }
|
// { file, name, picture }
|
||||||
|
|
@ -1501,6 +1525,13 @@ export default class RoomClient
|
||||||
|
|
||||||
async _loadDynamicImports()
|
async _loadDynamicImports()
|
||||||
{
|
{
|
||||||
|
({ default: createTorrent } = await import(
|
||||||
|
|
||||||
|
/* webpackPrefetch: true */
|
||||||
|
/* webpackChunkName: "createtorrent" */
|
||||||
|
'create-torrent'
|
||||||
|
));
|
||||||
|
|
||||||
({ default: WebTorrent } = await import(
|
({ default: WebTorrent } = await import(
|
||||||
|
|
||||||
/* webpackPrefetch: true */
|
/* webpackPrefetch: true */
|
||||||
|
|
@ -2364,7 +2395,10 @@ export default class RoomClient
|
||||||
store.dispatch(requestActions.notify(
|
store.dispatch(requestActions.notify(
|
||||||
{
|
{
|
||||||
type : 'error',
|
type : 'error',
|
||||||
text : intl.formatMessage({ id: 'filesharing.error', defaultMessage: 'There was a filesharing error' })
|
text : intl.formatMessage({
|
||||||
|
id : 'filesharing.error',
|
||||||
|
defaultMessage : 'There was a filesharing error'
|
||||||
|
})
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue