Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function init () {
if (!WebTorrent.WEBRTC_SUPPORT) {
util.error('This browser is unsupported. Please use a browser with WebRTC support.')
}
// For performance, create the client immediately
getClient(function () {})
// Seed via upload input element
var upload = document.querySelector('input[name=upload]')
if (upload) {
uploadElement(upload, function (err, files) {
if (err) return util.error(err)
files = files.map(function (file) { return file.file })
onFiles(files)
})
}
peerPublicKey: peerPublicKey,
amount: incoming.destinationAmount
})
// Unchoke all of this peer's wires
for (let wire of this.peerWires[peerPublicKey]) {
wire.unchoke()
wire.bidAmount = wire.bidAmount.times(this.bidIncreaseFactor)
this._checkUnchokeWire(wire)
}
}
}
// Note that using module.exports instead of export const here is a hack
// to make this work with https://github.com/59naga/babel-plugin-add-module-exports
module.exports.WEBRTC_SUPPORT = WebTorrent.WEBRTC_SUPPORT
export const configureDragDrop = () =>
{
if (WebTorrent.WEBRTC_SUPPORT)
{
dragDrop('body', async (files) => await shareFiles(files));
}
};
render()
{
return (
<div>
<img src="{this.props.data.picture">
<div>
{this.props.data.me ? (
<p>You shared a file.</p>
) : (
<p>{this.props.data.name} shared a file.</p>
)}
{!this.state.active && !this.state.files && (
<div>
{WebTorrent.WEBRTC_SUPPORT ? (
<span>
<img src="resources/images/download-icon.svg">
</span>
) : (
<p>
Your browser does not support downloading files using WebTorrent.
</p>
)}
<p>{magnet.decode(this.props.data.file.magnet).dn}</p>
</div>
)}
{this.state.active && this.state.numPeers === 0 && (
<p></p></div></div>