-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sean Yesmunt
committed
Jun 3, 2019
1 parent
90e5a48
commit 3fbf8ca
Showing
5 changed files
with
61 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,66 @@ | ||
// @flow | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { PAGES } from 'lbry-redux'; | ||
import Button from 'component/button'; | ||
import FileList from 'component/fileList'; | ||
import Page from 'component/page'; | ||
import { PAGES } from 'lbry-redux'; | ||
import { FormField } from 'component/common/form'; | ||
import usePersistedState from 'util/use-persisted-state'; | ||
|
||
type Props = { | ||
fetching: boolean, | ||
fileInfos: {}, | ||
downloadedUris: Array<string>, | ||
sortBy: string, | ||
}; | ||
|
||
class FileListDownloaded extends React.PureComponent<Props> { | ||
render() { | ||
const { fetching, fileInfos, sortBy } = this.props; | ||
const hasDownloads = fileInfos && Object.values(fileInfos).length > 0; | ||
function FileListDownloaded(props: Props) { | ||
const { fetching, downloadedUris, sortBy } = props; | ||
const [newestFirst, setNewestFirst] = usePersistedState('file-list-download', true); | ||
|
||
function toggleNewestFirst() { | ||
setNewestFirst(!newestFirst); | ||
} | ||
|
||
const hasDownloads = !!downloadedUris.length; | ||
|
||
return ( | ||
// Removed the <Page> wapper to try combining this page with UserHistory | ||
// This should eventually move into /components if we want to keep it this way | ||
<React.Fragment> | ||
{hasDownloads ? ( | ||
<div className="card"> | ||
<FileList | ||
uris={fileInfos.map(info => `lbry://${info.claim_name}#${info.claim_id}`)} | ||
header={<h1>Add Sort Here</h1>} | ||
/> | ||
</div> | ||
) : ( | ||
<div className="main--empty"> | ||
<section className="card card--section"> | ||
<header className="card__header"> | ||
<h2 className="card__title">{__("You haven't downloaded anything from LBRY yet.")}</h2> | ||
</header> | ||
return ( | ||
// Removed the <Page> wapper to try combining this page with UserHistory | ||
// This should eventually move into /components if we want to keep it this way | ||
<React.Fragment> | ||
{hasDownloads ? ( | ||
<div className="card"> | ||
<FileList | ||
header={ | ||
<FormField | ||
type="select" | ||
name="trending_sort" | ||
value={newestFirst ? 'new' : 'old'} | ||
onChange={() => setNewestFirst(!newestFirst)} | ||
> | ||
<option value="new">{__('Newest First')}</option> | ||
<option value="old">{__('Oldest First')}</option> | ||
</FormField> | ||
} | ||
uris={newestFirst ? downloadedUris : downloadedUris.reverse()} | ||
/> | ||
</div> | ||
) : ( | ||
<div className="main--empty"> | ||
<section className="card card--section"> | ||
<header className="card__header"> | ||
<h2 className="card__title">{__("You haven't downloaded anything from LBRY yet.")}</h2> | ||
</header> | ||
|
||
<div className="card__content"> | ||
<div className="card__actions card__actions--center"> | ||
<Button button="primary" navigate="/" label={__('Explore new content')} /> | ||
</div> | ||
<div className="card__content"> | ||
<div className="card__actions card__actions--center"> | ||
<Button button="primary" navigate="/" label={__('Explore new content')} /> | ||
</div> | ||
</section> | ||
</div> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
</div> | ||
</section> | ||
</div> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
export default FileListDownloaded; |