From 3721dcd474cd8def3dc53ca9b239b504cc25395d Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Fri, 1 Nov 2019 13:27:01 -0400 Subject: [PATCH] WIP fixes and improvements --- src/ui/component/app/index.js | 12 ++----- src/ui/component/app/view.jsx | 10 +++--- src/ui/component/fileProperties/view.jsx | 3 ++ .../publishAdditionalOptions/index.js | 31 +------------------ src/ui/component/publishFile/view.jsx | 17 +++++++--- src/ui/component/publishForm/index.js | 2 +- src/ui/component/publishForm/view.jsx | 6 ++-- src/ui/component/selectThumbnail/index.js | 22 +------------ src/ui/component/transactionList/view.jsx | 2 +- .../component/transactionListRecent/index.js | 13 ++++---- .../component/transactionListRecent/view.jsx | 13 ++++---- .../transactionRefreshButton/index.js | 2 +- .../transactionRefreshButton/view.jsx | 11 +++++-- src/ui/component/walletAddress/view.jsx | 3 +- src/ui/component/walletBackup/view.jsx | 2 +- src/ui/constants/claim.js | 1 + src/ui/modal/modalPublish/view.jsx | 24 +++++++++----- src/ui/page/transactionHistory/index.js | 10 ++---- src/ui/page/transactionHistory/view.jsx | 8 ++--- src/ui/redux/actions/publish.js | 4 +-- 20 files changed, 80 insertions(+), 116 deletions(-) diff --git a/src/ui/component/app/index.js b/src/ui/component/app/index.js index b4fc3cdb8..d29bc7b58 100644 --- a/src/ui/component/app/index.js +++ b/src/ui/component/app/index.js @@ -1,14 +1,7 @@ import * as SETTINGS from 'constants/settings'; import { hot } from 'react-hot-loader/root'; import { connect } from 'react-redux'; -import { - selectUser, - doRewardList, - doFetchRewardedContent, - doFetchAccessToken, - selectGetSyncErrorMessage, - selectUploadCount, -} from 'lbryinc'; +import { selectUser, doRewardList, doFetchAccessToken, selectGetSyncErrorMessage, selectUploadCount } from 'lbryinc'; import { doFetchTransactions, doFetchChannelListMine } from 'lbry-redux'; import { makeSelectClientSetting, selectThemePath } from 'redux/selectors/settings'; import { selectIsUpgradeAvailable, selectAutoUpdateDownloaded } from 'redux/selectors/app'; @@ -28,8 +21,7 @@ const select = state => ({ const perform = dispatch => ({ fetchRewards: () => dispatch(doRewardList()), - fetchRewardedContent: () => dispatch(doFetchRewardedContent()), - fetchTransactions: () => dispatch(doFetchTransactions()), + fetchTransactions: (page, pageSize) => dispatch(doFetchTransactions(page, pageSize)), fetchAccessToken: () => dispatch(doFetchAccessToken()), fetchChannelListMine: () => dispatch(doFetchChannelListMine()), signIn: () => dispatch(doSignIn()), diff --git a/src/ui/component/app/view.jsx b/src/ui/component/app/view.jsx index 9147cf825..67366d90c 100644 --- a/src/ui/component/app/view.jsx +++ b/src/ui/component/app/view.jsx @@ -1,6 +1,7 @@ // @flow import * as ICONS from 'constants/icons'; import * as PAGES from 'constants/pages'; +import { LATEST_PAGE_SIZE } from 'constants/claim'; import React, { useEffect, useRef, useState } from 'react'; import classnames from 'classnames'; import analytics from 'analytics'; @@ -31,8 +32,7 @@ type Props = { location: { pathname: string, hash: string }, history: { push: string => void }, fetchRewards: () => void, - fetchRewardedContent: () => void, - fetchTransactions: () => void, + fetchTransactions: (page, pageSize) => void, fetchAccessToken: () => void, fetchChannelListMine: () => void, signIn: () => void, @@ -53,7 +53,6 @@ function App(props: Props) { const { theme, fetchRewards, - fetchRewardedContent, fetchTransactions, user, fetchAccessToken, @@ -100,14 +99,13 @@ function App(props: Props) { useEffect(() => { ReactModal.setAppElement(appRef.current); fetchAccessToken(); - fetchRewardedContent(); // @if TARGET='app' fetchRewards(); - fetchTransactions(); + fetchTransactions(1, LATEST_PAGE_SIZE); fetchChannelListMine(); // This needs to be done for web too... // @endif - }, [fetchRewards, fetchRewardedContent, fetchTransactions, fetchAccessToken, fetchChannelListMine]); + }, [fetchRewards, fetchTransactions, fetchAccessToken, fetchChannelListMine]); useEffect(() => { // $FlowFixMe diff --git a/src/ui/component/fileProperties/view.jsx b/src/ui/component/fileProperties/view.jsx index 80327886d..f51ae0061 100644 --- a/src/ui/component/fileProperties/view.jsx +++ b/src/ui/component/fileProperties/view.jsx @@ -25,6 +25,9 @@ export default function FileProperties(props: Props) { {isSubscribed && } {!claimIsMine && downloaded && } {isRewardContent && } + trending group:{claim.meta.trending_group} + trending mixed:{claim.meta.trending_mixed} + {claim.meta.support_amount} diff --git a/src/ui/component/publishAdditionalOptions/index.js b/src/ui/component/publishAdditionalOptions/index.js index fdb542edb..fa963ea73 100644 --- a/src/ui/component/publishAdditionalOptions/index.js +++ b/src/ui/component/publishAdditionalOptions/index.js @@ -1,42 +1,13 @@ import { connect } from 'react-redux'; -import { - doResolveUri, - selectBalance, - selectPublishFormValues, - selectIsStillEditing, - selectMyClaimForUri, - selectIsResolvingPublishUris, - selectTakeOverAmount, - doResetThumbnailStatus, - doClearPublish, - doUpdatePublishForm, - doPrepareEdit, -} from 'lbry-redux'; -import { doPublishDesktop } from 'redux/actions/publish'; -import { selectUnclaimedRewardValue } from 'lbryinc'; +import { selectPublishFormValues, doUpdatePublishForm } from 'lbry-redux'; import PublishPage from './view'; const select = state => ({ ...selectPublishFormValues(state), - // The winning claim for a short lbry uri - amountNeededForTakeover: selectTakeOverAmount(state), - // My previously published claims under this short lbry uri - myClaimForUri: selectMyClaimForUri(state), - // If I clicked the "edit" button, have I changed the uri? - // Need this to make it easier to find the source on previously published content - isStillEditing: selectIsStillEditing(state), - isResolvingUri: selectIsResolvingPublishUris(state), - totalRewardValue: selectUnclaimedRewardValue(state), - balance: selectBalance(state), }); const perform = dispatch => ({ updatePublishForm: value => dispatch(doUpdatePublishForm(value)), - clearPublish: () => dispatch(doClearPublish()), - resolveUri: uri => dispatch(doResolveUri(uri)), - publish: () => dispatch(doPublishDesktop()), - prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)), - resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()), }); export default connect( diff --git a/src/ui/component/publishFile/view.jsx b/src/ui/component/publishFile/view.jsx index ae5ba97f5..dc4923fd8 100644 --- a/src/ui/component/publishFile/view.jsx +++ b/src/ui/component/publishFile/view.jsx @@ -1,6 +1,6 @@ // @flow import * as ICONS from 'constants/icons'; -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { regexInvalidURI } from 'lbry-redux'; import FileSelector from 'component/common/file-selector'; import Button from 'component/button'; @@ -32,6 +32,12 @@ function PublishFile(props: Props) { } } + useEffect(() => { + if (currentFile) { + updatePublishForm(); + } + }, [currentFile]); + function handleFileChange(file: WebFile) { // if electron, we'll set filePath to the path string because SDK is handling publishing. // if web, we set the filePath (dumb name) to the File() object @@ -52,10 +58,13 @@ function PublishFile(props: Props) { // @endif const publishFormParams: { filePath: string | WebFile, name?: string } = { filePath: file.path || file, - name: file.name, + name: '', }; - const parsedFileName = file.name.replace(regexInvalidURI, ''); - publishFormParams.name = parsedFileName.replace(' ', '-'); + // Strip off extention and replace invalid characters + let fileName = file.name.substr(0, file.name.lastIndexOf('.')) || file.name; + let replaceChars = new RegExp(regexInvalidURI, 'gu'); + let parsedFileName = fileName.replace(replaceChars, '-'); + publishFormParams.name = parsedFileName; updatePublishForm(publishFormParams); } diff --git a/src/ui/component/publishForm/index.js b/src/ui/component/publishForm/index.js index 8b8457aa9..38bc6b384 100644 --- a/src/ui/component/publishForm/index.js +++ b/src/ui/component/publishForm/index.js @@ -32,7 +32,7 @@ const perform = dispatch => ({ updatePublishForm: value => dispatch(doUpdatePublishForm(value)), clearPublish: () => dispatch(doClearPublish()), resolveUri: uri => dispatch(doResolveUri(uri)), - publish: () => dispatch(doPublishDesktop()), + publish: filePath => dispatch(doPublishDesktop(filePath)), prepareEdit: (claim, uri) => dispatch(doPrepareEdit(claim, uri)), resetThumbnailStatus: () => dispatch(doResetThumbnailStatus()), }); diff --git a/src/ui/component/publishForm/view.jsx b/src/ui/component/publishForm/view.jsx index f5b961e74..f0e1c12df 100644 --- a/src/ui/component/publishForm/view.jsx +++ b/src/ui/component/publishForm/view.jsx @@ -26,7 +26,7 @@ import Card from 'component/common/card'; type Props = { disabled: boolean, tags: Array, - publish: PublishParams => void, + publish: string => void, filePath: ?string, bid: ?number, editingURI: ?string, @@ -112,7 +112,7 @@ function PublishForm(props: Props) { // We are only going to store the full uri, but we need to resolve the uri with and without the channel name let uri; try { - uri = buildURI({ streamName: name, channelName }); + uri = name && buildURI({ streamName: name, channelName }); } catch (e) {} if (channelName && name) { @@ -182,7 +182,7 @@ function PublishForm(props: Props) {

- {__('You can generate a new address at any time, and any previous addresses will continue to work.')} + {!IS_WEB && + __('You can generate a new address at any time, and any previous addresses will continue to work.')}

{showQR && } diff --git a/src/ui/component/walletBackup/view.jsx b/src/ui/component/walletBackup/view.jsx index a95d7dc6c..12606e7ae 100644 --- a/src/ui/component/walletBackup/view.jsx +++ b/src/ui/component/walletBackup/view.jsx @@ -102,7 +102,7 @@ class WalletBackup extends React.PureComponent {
  • {__( - 'Currently, there is no automatic backup. If you lose access to these files, you will lose your credits.' + 'If Sync is on, LBRY will backup your wallet and preferences. If disabled, you are responsible for keeping a backup.' )}
  • diff --git a/src/ui/constants/claim.js b/src/ui/constants/claim.js index 83f9fb9ea..4df3010c4 100644 --- a/src/ui/constants/claim.js +++ b/src/ui/constants/claim.js @@ -3,6 +3,7 @@ export const MINIMUM_PUBLISH_BID = 0.00000001; export const CHANNEL_ANONYMOUS = 'anonymous'; export const CHANNEL_NEW = 'new'; export const PAGE_SIZE = 20; +export const LATEST_PAGE_SIZE = 20; export const INVALID_NAME_ERROR = __('LBRY names cannot contain spaces or reserved symbols') + ' ' + '($#@;/"<>%{}|^~[]`)'; diff --git a/src/ui/modal/modalPublish/view.jsx b/src/ui/modal/modalPublish/view.jsx index 3b8c27de9..3d519bea5 100644 --- a/src/ui/modal/modalPublish/view.jsx +++ b/src/ui/modal/modalPublish/view.jsx @@ -2,6 +2,7 @@ import React from 'react'; import { Modal } from 'modal/modal'; import ClaimPreview from 'component/claimPreview'; +import Button from 'component/button'; type Props = { closeModal: () => void, @@ -9,14 +10,14 @@ type Props = { navigate: string => void, uri: string, isEdit: boolean, + filePath: ?string, }; class ModalPublishSuccess extends React.PureComponent { render() { - const { closeModal, clearPublish, navigate, uri, isEdit } = this.props; - const contentLabel = isEdit ? 'Updates published' : 'File published'; - const publishMessage = isEdit ? 'updates have been' : 'file has been'; - const publishType = isEdit ? 'updates' : 'file'; + const { closeModal, clearPublish, navigate, uri, isEdit, filePath } = this.props; + const contentLabel = isEdit ? 'Update published' : 'File published'; + const publishMessage = isEdit ? 'update is now' : 'file is now'; return ( { closeModal(); }} > -

    {__(`Your %publishMessage% published to LBRY.`, { publishMessage })}

    +

    + {__(`Your %publishMessage% pending on LBRY. It will take a few minutes to appear for other users.`, { + publishMessage, + })} +

    - {__( - `The ${publishType} will take a few minutes to appear for other LBRY users. Until then it will be listed as "pending" under your published files.` + {filePath && !IS_WEB && ( + + {__( + `Upload will continue in the background, please do not shut down immediately. Leaving the app running helps the network, thank you!` + )}{' '} +