Support channel definitions from /file/list_homepage #1267

Merged
daovist merged 1 commit from explore-channels into master 2018-05-24 22:15:04 +02:00
5 changed files with 62 additions and 9 deletions

View file

@ -0,0 +1,18 @@
import { connect } from 'react-redux';
import { doFetchClaimsByChannel } from 'redux/actions/content';
import {
makeSelectClaimsInChannelForCurrentPage,
makeSelectFetchingChannelClaims,
} from 'lbry-redux';
import CategoryList from './view';
const select = (state, props) => ({
channelClaims: makeSelectClaimsInChannelForCurrentPage(props.categoryLink)(state),
fetching: makeSelectFetchingChannelClaims(props.categoryLink)(state),
});
const perform = dispatch => ({
fetchChannel: channel => dispatch(doFetchClaimsByChannel(channel)),
});
export default connect(select, perform)(CategoryList);

View file

@ -5,11 +5,15 @@ import ToolTip from 'component/common/tooltip';
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
import FileCard from 'component/fileCard';
import Button from 'component/button';
import * as icons from 'constants/icons';
import Claim from 'types/claim';
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
type Props = {
category: string,
names: Array<string>,
categoryLink?: string,
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
categoryLink: ?string,
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
fetching: boolean,
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
channelClaims: Array<Claim>,
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
fetchChannel: string => void,
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
};
type State = {
@ -18,6 +22,11 @@ type State = {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
};
class CategoryList extends React.PureComponent<Props, State> {
static defaultProps = {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
names: [],
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
categoryLink: '',
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
};
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
constructor() {
super();
@ -32,6 +41,11 @@ class CategoryList extends React.PureComponent<Props, State> {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
}
componentDidMount() {
const { fetching, categoryLink, fetchChannel } = this.props;
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
if (!fetching) {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
fetchChannel(categoryLink);
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
}
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
const cardRow = this.rowItems;
if (cardRow) {
const cards = cardRow.getElementsByTagName('section');
@ -109,6 +123,9 @@ class CategoryList extends React.PureComponent<Props, State> {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
// check if a card is fully visible horizontally
isCardVisible = (section: HTMLElement) => {
if (!section) {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
return false;
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
}
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
const rect = section.getBoundingClientRect();
const isVisible = rect.left >= 0 && rect.right <= window.innerWidth;
return isVisible;
@ -189,7 +206,7 @@ class CategoryList extends React.PureComponent<Props, State> {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
}
render() {
const { category, names, categoryLink } = this.props;
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
const { category, categoryLink, names, channelClaims } = this.props;
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
const { canScrollNext, canScrollPrevious } = this.state;
// The lint was throwing an error saying we should use <button> instead of <a>
@ -235,6 +252,12 @@ class CategoryList extends React.PureComponent<Props, State> {
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
className="card-row__scrollhouse"
>
{names && names.map(name => <FileCard key={name} uri={normalizeURI(name)} />)}
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
{channelClaims && channelClaims.length
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
? channelClaims.map(claim => (
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
<FileCard key={claim.claim_id} uri={`lbry://${claim.name}#${claim.claim_id}`} />
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
))
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
: null}
neb-b commented 2018-05-11 04:04:45 +02:00 (Migrated from github.com)
Review

You can use the Caim type that I recently created.

You can use the `Caim` type that I recently created.
</div>
</div>
);

View file

@ -1,7 +1,7 @@
// @flow
import React from 'react';
import Page from 'component/page';
import CategoryList from 'component/common/category-list';
import CategoryList from 'component/categoryList';
type Props = {
fetchFeaturedUris: () => void,
@ -27,7 +27,11 @@ class DiscoverPage extends React.PureComponent<Props> {
featuredUris[category].length ? (
<CategoryList key={category} category={category} names={featuredUris[category]} />
) : (
''
<CategoryList
key={category}
category={category.split('#')[0]}
categoryLink={category}
/>
)
)}
{failedToLoad && <div className="empty">{__('Failed to load landing content.')}</div>}

View file

@ -129,6 +129,14 @@ class FilePage extends React.Component<Props> {
subscriptionUri = buildURI({ channelName, claimId: channelClaimId }, false);
}
// We want to use the short form uri for editing
// This is what the user is used to seeing, they don't care about the claim id
// We will select the claim id before they publish
let editUri;
if (claimIsMine) {
editUri = buildURI({ channelName, contentName: claim.name });
}
const isPlaying = playingUri === uri && !isPaused;
return (
<Page extraPadding>
@ -170,7 +178,7 @@ class FilePage extends React.Component<Props> {
icon={icons.EDIT}
label={__('Edit')}
onClick={() => {
prepareEdit(claim, uri);
prepareEdit(claim, editUri);
navigate('/publish');
}}
/>

View file

@ -42,10 +42,10 @@ export function doFetchFeaturedUris() {
});
const success = ({ Uris }) => {
let urisToResolve = [];
Object.keys(Uris).forEach(category => {
urisToResolve = [...urisToResolve, ...Uris[category]];
});
const urisToResolve = Object.keys(Uris).reduce(
(resolve, category) => [...resolve, ...Uris[category]],
[]
);
const actions = [
doResolveUris(urisToResolve),