Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Yesmunt committed Jun 3, 2019
1 parent 90e5a48 commit 3fbf8ca
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 147 deletions.
82 changes: 0 additions & 82 deletions src/ui/component/fileList/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,85 +33,3 @@ export default function FileList(props) {
</section>
);
}

// export default FileList;

// this.sortFunctions = {
// [SORT_OPTIONS.DATE_NEW]: fileInfos =>
// this.props.sortByHeight
// ? fileInfos.sort((fileInfo1, fileInfo2) => {
// if(fileInfo1.confirmations < 1) {
// return -1;
// } else if(fileInfo2.confirmations < 1) {
// return 1;
// }

// const height1 = this.props.claimsById[fileInfo1.claim_id]
// ? this.props.claimsById[fileInfo1.claim_id].height
// : 0;
// const height2 = this.props.claimsById[fileInfo2.claim_id]
// ? this.props.claimsById[fileInfo2.claim_id].height
// : 0;

// if(height1 !== height2) {
// // flipped because heigher block height is newer
// return height2 - height1;
// }

// if(fileInfo1.absolute_channel_position && fileInfo2.absolute_channel_position) {
// return fileInfo1.absolute_channel_position - fileInfo2.absolute_channel_position;
// }

// return 0;
// })
// : [...fileInfos].reverse(),
// [SORT_OPTIONS.DATE_OLD]: fileInfos =>
// this.props.sortByHeight
// ? fileInfos.slice().sort((fileInfo1, fileInfo2) => {
// const height1 = this.props.claimsById[fileInfo1.claim_id]
// ? this.props.claimsById[fileInfo1.claim_id].height
// : 999999;
// const height2 = this.props.claimsById[fileInfo2.claim_id]
// ? this.props.claimsById[fileInfo2.claim_id].height
// : 999999;
// if(height1 < height2) {
// return -1;
// } else if(height1 > height2) {
// return 1;
// }
// return 0;
// })
// : fileInfos,
// [SORT_OPTIONS.TITLE]: fileInfos =>
// fileInfos.slice().sort((fileInfo1, fileInfo2) => {
// const getFileTitle = fileInfo => {
// const {value, name, claim_name: claimName} = fileInfo;
// if(value) {
// return value.title || claimName;
// }

// // Invalid claim
// return '';
// };
// const title1 = getFileTitle(fileInfo1).toLowerCase();
// const title2 = getFileTitle(fileInfo2).toLowerCase();
// if(title1 < title2) {
// return -1;
// } else if(title1 > title2) {
// return 1;
// }
// return 0;
// }),
// [SORT_OPTIONS.FILENAME]: fileInfos =>
// fileInfos.slice().sort(({file_name: fileName1}, {file_name: fileName2}) => {
// const fileName1Lower = fileName1.toLowerCase();
// const fileName2Lower = fileName2.toLowerCase();
// if(fileName1Lower < fileName2Lower) {
// return -1;
// } else if(fileName2Lower > fileName1Lower) {
// return 1;
// }
// return 0;
// }),
// };
// }
29 changes: 8 additions & 21 deletions src/ui/component/header/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,15 @@ const Header = (props: Props) => {
icon={ICONS.ACCOUNT}
navigate="/$/account"
/>
{/* <Button
className="header__navigation-item header__navigation-item--right-action"
activeClass="header__navigation-item--active"
description={__('Your wallet')}
title={`Your balance is ${balance} LBRY Credits`}
label={
<React.Fragment>
{roundedBalance} <LbcSymbol />
</React.Fragment>
}
navigate="/$/account"
/> */}

{/* <Button
className="header__navigation-item header__navigation-item--right-action"
activeClass="header__navigation-item--active"
// description={__('Publish content')}
icon={ICONS.UPLOAD}
iconSize={24}
// label={isUpgradeAvailable ? '' : __('Publish')}
navigate="/$/publish"
/> */}
<Button
className="header__navigation-item header__navigation-item--right-action"
activeClass="header__navigation-item--active"
description={__('Publish content')}
icon={ICONS.UPLOAD}
iconSize={24}
navigate="/$/publish"
/>

{/* @if TARGET='app' */}
{showUpgradeButton && (
Expand Down
2 changes: 1 addition & 1 deletion src/ui/component/navigationHistoryRecent/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default function NavigationHistoryRecent(props: Props) {
))}
</section>
<div className="card__actions">
<Button navigate="/$/history/all" button="link" label={__('See All Visited Links')} />
<Button navigate="/$/library/all" button="link" label={__('See All Visited Links')} />
</div>
</div>
) : null;
Expand Down
11 changes: 2 additions & 9 deletions src/ui/page/fileListDownloaded/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { connect } from 'react-redux';
import {
selectFileInfosDownloaded,
selectMyClaimsWithoutChannels,
selectIsFetchingFileList,
selectFileListDownloadedSort,
} from 'lbry-redux';
import { selectDownloadedUris, selectIsFetchingFileList } from 'lbry-redux';
import FileListDownloaded from './view';

const select = state => ({
fileInfos: selectFileInfosDownloaded(state),
downloadedUris: selectDownloadedUris(state),
fetching: selectIsFetchingFileList(state),
claims: selectMyClaimsWithoutChannels(state),
sortBy: selectFileListDownloadedSort(state),
});

export default connect(
Expand Down
84 changes: 50 additions & 34 deletions src/ui/page/fileListDownloaded/view.jsx
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;

0 comments on commit 3fbf8ca

Please sign in to comment.