From 4ecd5e16847e42403389c909b43d3b5fc2ad6322 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Wed, 21 Nov 2018 16:20:55 -0500 Subject: [PATCH 1/2] add recommended subscriptions --- .eslintrc.json | 1 + src/renderer/component/app/view.jsx | 2 +- src/renderer/component/categoryList/view.jsx | 46 ++++-- src/renderer/component/channelTile/view.jsx | 2 +- .../component/common/credit-amount.jsx | 2 +- .../component/common/file-exporter.jsx | 33 ++-- .../common/form-components/form-field.jsx | 2 +- src/renderer/component/fileCard/view.jsx | 2 +- src/renderer/component/header/index.js | 2 +- src/renderer/component/page/index.js | 2 +- .../component/subscribeButton/index.js | 9 +- .../component/subscribeButton/view.jsx | 26 ++- .../component/subscribeSuggested/index.js | 12 ++ .../component/subscribeSuggested/view.jsx | 23 +++ src/renderer/component/viewers/codeViewer.jsx | 2 +- src/renderer/component/viewers/htmlViewer.jsx | 2 +- src/renderer/component/viewers/pdfViewer.jsx | 2 +- src/renderer/component/wunderbar/view.jsx | 3 +- src/renderer/constants/action_types.js | 5 + src/renderer/constants/subscriptions.js | 5 + .../modal/modalFirstSubscription/index.js | 2 - .../modal/modalFirstSubscription/view.jsx | 19 +-- src/renderer/page/channel/view.jsx | 2 +- src/renderer/page/file/view.jsx | 4 +- src/renderer/page/subscriptions/index.js | 12 +- .../page/subscriptions/internal/first-run.jsx | 63 +++++++ .../internal/user-subscriptions.jsx | 134 +++++++++++++++ src/renderer/page/subscriptions/view.jsx | 154 ++++++------------ src/renderer/redux/actions/content.js | 6 +- src/renderer/redux/actions/file.js | 2 +- src/renderer/redux/actions/navigation.js | 2 +- src/renderer/redux/actions/subscriptions.js | 30 ++++ src/renderer/redux/reducers/subscriptions.js | 31 +++- src/renderer/redux/selectors/subscriptions.js | 68 ++++++++ src/renderer/scss/_gui.scss | 10 ++ .../scss/component/_subscriptions.scss | 23 +++ src/renderer/store.js | 10 +- src/renderer/types/subscription.js | 18 ++ .../util/{contextMenu.js => context-menu.js} | 0 .../{formatCredits.js => format-credits.js} | 0 .../{getMediaType.js => get-media-type.js} | 0 .../util/{parseData.js => parse-data.js} | 0 .../util/{query_params.js => query-params.js} | 0 .../util/{setBadge.js => set-badge.js} | 0 ...{setProgressBar.js => set-progress-bar.js} | 0 src/renderer/util/swap-json.js | 10 ++ static/img/gerbil-happy.png | Bin 0 -> 174280 bytes static/img/gerbil-sad.png | Bin 0 -> 177558 bytes 48 files changed, 594 insertions(+), 189 deletions(-) create mode 100644 src/renderer/component/subscribeSuggested/index.js create mode 100644 src/renderer/component/subscribeSuggested/view.jsx create mode 100644 src/renderer/page/subscriptions/internal/first-run.jsx create mode 100644 src/renderer/page/subscriptions/internal/user-subscriptions.jsx create mode 100644 src/renderer/scss/component/_subscriptions.scss rename src/renderer/util/{contextMenu.js => context-menu.js} (100%) rename src/renderer/util/{formatCredits.js => format-credits.js} (100%) rename src/renderer/util/{getMediaType.js => get-media-type.js} (100%) rename src/renderer/util/{parseData.js => parse-data.js} (100%) rename src/renderer/util/{query_params.js => query-params.js} (100%) rename src/renderer/util/{setBadge.js => set-badge.js} (100%) rename src/renderer/util/{setProgressBar.js => set-progress-bar.js} (100%) create mode 100644 src/renderer/util/swap-json.js create mode 100644 static/img/gerbil-happy.png create mode 100644 static/img/gerbil-sad.png 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 (