diff --git a/.eslintrc.json b/.eslintrc.json index a8f285504..22a808553 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -44,6 +44,7 @@ "jsx-a11y/interactive-supports-focus": 0, "jsx-a11y/click-events-have-key-events": 0, "consistent-return": 0, + "no-prototype-builtins": 0, "flowtype/space-after-type-colon": [ 2, "always", { "allowLineBreak": true } ] } } diff --git a/src/renderer/component/app/view.jsx b/src/renderer/component/app/view.jsx index 6aebf7706..eadfc77ab 100644 --- a/src/renderer/component/app/view.jsx +++ b/src/renderer/component/app/view.jsx @@ -6,7 +6,7 @@ import ReactModal from 'react-modal'; import throttle from 'util/throttle'; import SideBar from 'component/sideBar'; import Header from 'component/header'; -import { openContextMenu } from '../../util/contextMenu'; +import { openContextMenu } from '../../util/context-menu'; const TWO_POINT_FIVE_MINUTES = 1000 * 60 * 2.5; diff --git a/src/renderer/component/categoryList/view.jsx b/src/renderer/component/categoryList/view.jsx index cf39c06af..240460caf 100644 --- a/src/renderer/component/categoryList/view.jsx +++ b/src/renderer/component/categoryList/view.jsx @@ -1,18 +1,19 @@ // @flow -import * as React from 'react'; +import type { Claim } from 'types/claim'; +import React, { PureComponent } from 'react'; import { normalizeURI } from 'lbry-redux'; import ToolTip from 'component/common/tooltip'; import FileCard from 'component/fileCard'; import Button from 'component/button'; import * as icons from 'constants/icons'; -import type { Claim } from 'types/claim'; +import SubscribeButton from 'component/subscribeButton'; type Props = { category: string, - names: Array, + names: ?Array, categoryLink: ?string, fetching: boolean, - channelClaims: Array, + channelClaims: ?Array, fetchChannel: string => void, obscureNsfw: boolean, }; @@ -22,9 +23,8 @@ type State = { canScrollPrevious: boolean, }; -class CategoryList extends React.PureComponent { +class CategoryList extends PureComponent { static defaultProps = { - names: [], categoryLink: '', }; @@ -209,7 +209,6 @@ class CategoryList extends React.PureComponent { render() { const { category, categoryLink, names, channelClaims, obscureNsfw } = this.props; const { canScrollNext, canScrollPrevious } = this.state; - const isCommunityTopBids = category.match(/^community/i); const showScrollButtons = isCommunityTopBids ? !obscureNsfw : true; @@ -218,7 +217,10 @@ class CategoryList extends React.PureComponent {
{categoryLink ? ( -
) : ( category )} @@ -263,19 +265,33 @@ class CategoryList extends React.PureComponent { }} > {names && + names.length && names.map(name => ( ))} {channelClaims && channelClaims.length && - channelClaims.map(claim => ( - - ))} + channelClaims + // Only show the first 10 claims, regardless of the amount we have on a channel page + .slice(0, 10) + .map(claim => ( + + ))} + {/* + If there aren't any uris passed in, create an empty array and render placeholder cards + channelClaims or names are being fetched + */} + {!channelClaims && + !names && + /* eslint-disable react/no-array-index-key */ + new Array(10).fill(1).map((x, i) => ) + /* eslint-enable react/no-array-index-key */ + }
)} diff --git a/src/renderer/component/channelTile/view.jsx b/src/renderer/component/channelTile/view.jsx index 8edbc1e03..6bde45cd8 100644 --- a/src/renderer/component/channelTile/view.jsx +++ b/src/renderer/component/channelTile/view.jsx @@ -76,7 +76,7 @@ class ChannelTile extends React.PureComponent { )} {subscriptionUri && (
- +
)} diff --git a/src/renderer/component/common/credit-amount.jsx b/src/renderer/component/common/credit-amount.jsx index 0f8d89338..b15ba435a 100644 --- a/src/renderer/component/common/credit-amount.jsx +++ b/src/renderer/component/common/credit-amount.jsx @@ -1,7 +1,7 @@ // @flow import React from 'react'; import classnames from 'classnames'; -import { formatCredits, formatFullPrice } from 'util/formatCredits'; +import { formatCredits, formatFullPrice } from 'util/format-credits'; type Props = { amount: number, diff --git a/src/renderer/component/common/file-exporter.jsx b/src/renderer/component/common/file-exporter.jsx index fe32fa1d4..18364dd79 100644 --- a/src/renderer/component/common/file-exporter.jsx +++ b/src/renderer/component/common/file-exporter.jsx @@ -3,7 +3,7 @@ import fs from 'fs'; import path from 'path'; import React from 'react'; import Button from 'component/button'; -import parseData from 'util/parseData'; +import parseData from 'util/parse-data'; import * as icons from 'constants/icons'; import { remote } from 'electron'; @@ -33,7 +33,10 @@ class FileExporter extends React.PureComponent { fs.writeFile(filename, data, err => { if (err) throw err; // Do something after creation - onFileCreated && onFileCreated(filename); + + if (onFileCreated) { + onFileCreated(filename); + } }); } @@ -55,24 +58,22 @@ class FileExporter extends React.PureComponent { ], }; - remote.dialog.showSaveDialog( - remote.getCurrentWindow(), - options, - filename => { - // User hit cancel so do nothing: - if (!filename) return; - // Get extension and remove initial dot - const format = path.extname(filename).replace(/\./g, ''); - // Parse data to string with the chosen format - const parsed = parseData(data, format, filters); - // Write file - parsed && this.handleFileCreation(filename, parsed); + remote.dialog.showSaveDialog(remote.getCurrentWindow(), options, filename => { + // User hit cancel so do nothing: + if (!filename) return; + // Get extension and remove initial dot + const format = path.extname(filename).replace(/\./g, ''); + // Parse data to string with the chosen format + const parsed = parseData(data, format, filters); + // Write file + if (parsed) { + this.handleFileCreation(filename, parsed); } - ); + }); } render() { - const { title, label } = this.props; + const { label } = this.props; return (