Fixing sizes.

This commit is contained in:
Dessalines 2019-08-21 15:12:04 -07:00
parent 61c93ec260
commit 4c2d438507
1 changed files with 17 additions and 17 deletions

View File

@ -1,5 +1,5 @@
import { Component, linkEvent } from 'inferno';
import * as moment from 'moment';
import moment from 'moment';
import { endpoint } from '../env';
import { SearchParams, Results, Torrent } from '../interfaces';
@ -55,17 +55,17 @@ export class Search extends Component<any, State> {
if (!!this.state.searchParams.q) {
this.setState({ searching: true, results: { torrents: [] } });
this.fetchData(this.state.searchParams)
.then(torrents => {
if (!!torrents) {
this.setState({
results: {
torrents: torrents
}
});
}
}).catch(error => {
console.error('request failed', error);
}).then(() => this.setState({ searching: false }));
.then(torrents => {
if (!!torrents) {
this.setState({
results: {
torrents: torrents
}
});
}
}).catch(error => {
console.error('request failed', error);
}).then(() => this.setState({ searching: false }));
} else {
this.setState({ results: { torrents: [] } });
}
@ -74,7 +74,7 @@ export class Search extends Component<any, State> {
fetchData(searchParams: SearchParams): Promise<Array<Torrent>> {
let q = encodeURI(searchParams.q);
return fetch(`${endpoint}/service/search?q=${q}&page=${searchParams.page}&type_=${searchParams.type_}`)
.then(data => data.json());
.then(data => data.json());
}
render() {
@ -83,8 +83,8 @@ export class Search extends Component<any, State> {
{
this.state.searching ?
this.spinner() : this.state.results.torrents[0] ?
this.torrentsTable()
: this.noResults()
this.torrentsTable()
: this.noResults()
}
</div>
);
@ -138,7 +138,7 @@ export class Search extends Component<any, State> {
</a>
</td>
)}
<td class="text-right text-muted">{humanFileSize(torrent.size_bytes, true)}</td>
<td class="text-right text-muted">{humanFileSize(torrent.size_bytes, false)}</td>
<td class="text-right text-success">
<svg class="icon icon-arrow-up d-none d-sm-inline mr-1"><use xlinkHref="#icon-arrow-up"></use></svg>
<span>{torrent.seeders}</span>
@ -190,7 +190,7 @@ export class Search extends Component<any, State> {
<button class="page-link"
onClick={linkEvent({ i: this, nextPage: true }, this.switchPage)}>
Next
</button>
</button>
</li>
</ul>
</nav>