Major cleanup

This commit is contained in:
Håvar Aambø Fosstveit
2018-12-12 22:28:33 +01:00
parent fa91d9b9e2
commit 60fb9c735e
32 changed files with 506 additions and 16543 deletions
+28 -23
View File
@@ -110,29 +110,34 @@ class FileEntry extends Component
<img className='file-avatar' src={this.props.data.picture || DEFAULT_PICTURE} />
<div className='file-content'>
{this.props.data.me ? (
<p>You shared a file.</p>
) : (
<p>{this.props.data.name} shared a file.</p>
)}
<Choose>
<When condition={this.props.data.me}>
<p>You shared a file.</p>
</When>
<Otherwise>
<p>{this.props.data.name} shared a file.</p>
</Otherwise>
</Choose>
{!this.state.active && !this.state.files && (
<If condition={!this.state.active && !this.state.files}>
<div className='file-info'>
{WebTorrent.WEBRTC_SUPPORT ? (
<span className='button' onClick={this.handleDownload}>
<img src='resources/images/download-icon.svg' />
</span>
) : (
<p>
Your browser does not support downloading files using WebTorrent.
</p>
)}
<Choose>
<When condition={WebTorrent.WEBRTC_SUPPORT}>
<span className='button' onClick={this.handleDownload}>
<img src='resources/images/download-icon.svg' />
</span>
</When>
<Otherwise>
<p>
Your browser does not support downloading files using WebTorrent.
</p>
</Otherwise>
</Choose>
<p>{magnet.decode(this.props.data.file.magnet).dn}</p>
</div>
)}
</If>
{this.state.active && this.state.numPeers === 0 && (
<If condition={this.state.active && this.state.numPeers === 0}>
<Fragment>
<p>
Locating peers
@@ -145,13 +150,13 @@ class FileEntry extends Component
</p>
)}
</Fragment>
)}
</If>
{this.state.active && this.state.numPeers > 0 && (
<If condition={this.state.active && this.state.numPeers > 0}>
<progress value={this.state.progress} />
)}
</If>
{this.state.files && (
<If condition={this.state.files}>
<Fragment>
<p>Torrent finished downloading.</p>
@@ -165,7 +170,7 @@ class FileEntry extends Component
</div>
))}
</Fragment>
)}
</If>
</div>
</div>
);
@@ -17,17 +17,23 @@ class SharedFilesList extends Component
return (
<div className='shared-files'>
{ sharing.length > 0 ?
sharing.map((entry, i) => (
<FileEntry
data={entry}
key={i}
/>
))
:<div className='empty'>
<p>No one has shared files yet...</p>
</div>
}
<Choose>
<When condition={sharing.length > 0}>
{
sharing.map((entry, i) => (
<FileEntry
data={entry}
key={i}
/>
))
}
</When>
<Otherwise>
<div className='empty'>
<p>No one has shared files yet...</p>
</div>
</Otherwise>
</Choose>
</div>
);
}