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