add torrents sort icon

This commit is contained in:
nikk gitanes
2023-03-09 01:02:08 +03:00
parent e55a80963f
commit 97ba2e573f
2 changed files with 21 additions and 4 deletions

View File

@@ -5,7 +5,7 @@ import { TorrentListWrapper, CenteredGrid } from 'components/App/style'
import NoServerConnection from './NoServerConnection'
import AddFirstTorrent from './AddFirstTorrent'
export default function TorrentList({ isOffline, isLoading, torrents }) {
export default function TorrentList({ isOffline, isLoading, sortABC, torrents }) {
if (isLoading || isOffline || !torrents.length) {
return (
<CenteredGrid>
@@ -20,7 +20,15 @@ export default function TorrentList({ isOffline, isLoading, torrents }) {
)
}
return (
return sortABC ? (
<TorrentListWrapper>
{torrents
.sort((a, b) => a.title > b.title)
.map(torrent => (
<TorrentCard key={torrent.hash} torrent={torrent} />
))}
</TorrentListWrapper>
) : (
<TorrentListWrapper>
{torrents.map(torrent => (
<TorrentCard key={torrent.hash} torrent={torrent} />