lbry-desktop/ui/page/home/view.jsx

85 lines
2.5 KiB
React
Raw Normal View History

2020-01-02 17:30:27 +01:00
// @flow
2020-01-20 17:47:03 +01:00
import * as ICONS from 'constants/icons';
import * as PAGES from 'constants/pages';
2020-01-02 17:30:27 +01:00
import React from 'react';
import Page from 'component/page';
2020-01-20 17:47:03 +01:00
import Button from 'component/button';
import ClaimTilesDiscover from 'component/claimTilesDiscover';
2020-02-17 20:12:28 +01:00
import I18nMessage from 'component/i18nMessage';
import getHomepage from 'homepage';
2020-07-23 16:22:57 +02:00
2020-01-20 17:47:03 +01:00
type Props = {
authenticated: boolean,
followedTags: Array<Tag>,
subscribedChannels: Array<Subscription>,
};
2020-01-02 17:30:27 +01:00
2020-01-20 17:47:03 +01:00
type RowDataItem = {
title: string,
link?: string,
help?: any,
options?: {},
};
function HomePage(props: Props) {
const { followedTags, subscribedChannels, authenticated } = props;
const showPersonalizedChannels = (authenticated || !IS_WEB) && subscribedChannels && subscribedChannels.length > 0;
const showPersonalizedTags = (authenticated || !IS_WEB) && followedTags && followedTags.length > 0;
const showIndividualTags = showPersonalizedTags && followedTags.length < 5;
2020-02-06 21:11:00 +01:00
const rowData: Array<RowDataItem> = getHomepage(
authenticated,
showPersonalizedChannels,
showPersonalizedTags,
subscribedChannels,
followedTags,
showIndividualTags
);
2020-01-02 17:30:27 +01:00
return (
<Page>
2020-02-17 20:12:28 +01:00
{(authenticated || !IS_WEB) && !subscribedChannels.length && (
<div className="notice-message">
<h1 className="section__title">{__('LBRY Works Better If You Are Following Channels')}</h1>
<p className="section__subtitle">
<I18nMessage
tokens={{
discover_channels_link: (
<Button
button="link"
navigate={`/$/${PAGES.CHANNELS_FOLLOWING_DISCOVER}`}
label={__('Find new channels to follow')}
/>
),
}}
>
You aren't currently following any channels. %discover_channels_link%.
</I18nMessage>
</p>
</div>
)}
2020-01-20 17:47:03 +01:00
{rowData.map(({ title, link, help, options = {} }) => (
<div key={title} className="claim-grid__wrapper">
<h1 className="section__actions">
2020-07-22 22:32:18 +02:00
<span className="claim-grid__title">{title}</span>
2020-01-20 17:47:03 +01:00
{help}
</h1>
<ClaimTilesDiscover {...options} />
2020-07-22 22:32:18 +02:00
{link && (
<Button
className="claim-grid__title--secondary"
button="link"
navigate={link}
iconRight={ICONS.ARROW_RIGHT}
label={title}
/>
)}
2020-01-20 17:47:03 +01:00
</div>
))}
2020-01-02 17:30:27 +01:00
</Page>
);
}
export default HomePage;