Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel page caching #1750

Merged
merged 1 commit into from
Jul 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/renderer/component/common/busy-indicator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ type Props = {
message: ?string,
};

const BusyIndicator = (props: Props) => (
<span className="busy-indicator">
{props.message} <span className="busy-indicator__loader" />
</span>
);
class BusyIndicator extends React.PureComponent<Props> {
static defaultProps = {
message: '',
};

render() {
const { message } = this.props;

return (
<span className="busy-indicator">
{message} <span className="busy-indicator__loader" />
</span>
);
}
}

export default BusyIndicator;
25 changes: 12 additions & 13 deletions src/renderer/page/channel/view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ChannelPage extends React.PureComponent<Props> {
this.props.navigate('/show', newParams);
}

paginate(e, totalPages: number) {
paginate(e: SyntheticKeyboardEvent<*>, totalPages: number) {
// Change page if enter was pressed, and the given page is between
// the first and the last.
const pageFromInput = Number(e.target.value);
Expand All @@ -67,22 +67,21 @@ class ChannelPage extends React.PureComponent<Props> {
const { fetching, claimsInChannel, claim, page, totalPages } = this.props;
const { name, permanent_url: permanentUrl, claim_id: claimId } = claim;
const currentPage = parseInt((page || 1) - 1, 10);
let contentList;
if (fetching) {
contentList = <BusyIndicator message={__('Fetching content')} />;
} else {
contentList =
claimsInChannel && claimsInChannel.length ? (
<FileList sortByHeight hideFilter fileInfos={claimsInChannel} />
) : (
<span className="empty">{__('No content found.')}</span>
);
}

const contentList =
claimsInChannel && claimsInChannel.length ? (
<FileList sortByHeight hideFilter fileInfos={claimsInChannel} />
) : (
!fetching && <span className="empty">{__('No content found.')}</span>
);

return (
<Page notContained>
<section className="card__channel-info card__channel-info--large">
<h1>{name}</h1>
<h1>
{name}
{fetching && <BusyIndicator />}
</h1>
<div className="card__actions card__actions--no-margin">
<SubscribeButton uri={permanentUrl} channelName={name} />
<ViewOnWebButton claimId={claimId} claimName={name} />
Expand Down