From 951190bf96aa6a74f6101e2427e588c4b4c4acaf Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Sun, 21 May 2017 10:42:34 -0400 Subject: [PATCH] channel and file selector fixes --- ui/js/actions/content.js | 10 +-- ui/js/actions/cost_info.js | 2 +- ui/js/component/fileActions/view.jsx | 2 +- ui/js/component/form.js | 4 +- ui/js/component/reward-link.js | 4 +- ui/js/component/uriIndicator/index.js | 17 ++++- ui/js/component/uriIndicator/view.jsx | 98 +++++++++++++++++---------- ui/js/page/channel/index.js | 3 - ui/js/page/channel/view.jsx | 21 +++--- ui/js/page/filePage/index.js | 4 ++ ui/js/page/filePage/view.jsx | 9 ++- ui/js/page/search/view.jsx | 2 - ui/js/page/settings/view.jsx | 12 ++-- ui/js/page/showPage/view.jsx | 2 +- ui/js/reducers/claims.js | 16 +++++ 15 files changed, 127 insertions(+), 79 deletions(-) diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index 40ff1b048..efb1851e2 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -26,6 +26,8 @@ import { export function doResolveUri(uri) { return function(dispatch, getState) { + uri = lbryuri.normalize(uri) + const state = getState() const alreadyResolving = selectResolvingUris(state).indexOf(uri) !== -1 @@ -81,14 +83,6 @@ export function doFetchFeaturedUris() { featuredUris[category] = Uris[category] } }) - // - // dispatch({ - // type: types.FETCH_FEATURED_CONTENT_COMPLETED, - // data: { - // categories: ["FOO"], - // uris: { FOO: ["lbry://gtasoc"]}, - // } - // }) dispatch({ type: types.FETCH_FEATURED_CONTENT_COMPLETED, diff --git a/ui/js/actions/cost_info.js b/ui/js/actions/cost_info.js index 79ff4bdd5..dbad86f33 100644 --- a/ui/js/actions/cost_info.js +++ b/ui/js/actions/cost_info.js @@ -1,4 +1,4 @@ -import * as types from 'constants/action_types' + import * as types from 'constants/action_types' import lbry from 'lbry' import lbryio from 'lbryio' import { diff --git a/ui/js/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index 44eb4ade3..4924d059d 100644 --- a/ui/js/component/fileActions/view.jsx +++ b/ui/js/component/fileActions/view.jsx @@ -118,7 +118,7 @@ class FileActions extends React.Component { openModal('confirmRemove')} label="Remove..." /> : '' } + contentLabel="Confirm Purchase" onConfirmed={this.onAffirmPurchase.bind(this)} onAborted={this.props.closeModal}> This will purchase {title} for credits. : element } { formFieldFileSelectorTypes.includes(this.props.type) ? - : null } { this.props.postfix ? {this.props.postfix} : '' } diff --git a/ui/js/component/reward-link.js b/ui/js/component/reward-link.js index 43d3d61e8..31bd90e28 100644 --- a/ui/js/component/reward-link.js +++ b/ui/js/component/reward-link.js @@ -30,11 +30,11 @@ export class RewardLink extends React.Component { return; case 'first_publish': - lbry.claim_list_mine().then(function(list) { + lbry.claim_list_mine().then((list) => { this.setState({ claimable: list.length > 0 }) - }.bind(this)); + }); return; } } diff --git a/ui/js/component/uriIndicator/index.js b/ui/js/component/uriIndicator/index.js index 6cadf91b3..95806598d 100644 --- a/ui/js/component/uriIndicator/index.js +++ b/ui/js/component/uriIndicator/index.js @@ -1,20 +1,31 @@ import React from 'react' +import lbryuri from 'lbryuri'; import { connect, } from 'react-redux' +import { + makeSelectIsResolvingForUri +} from 'selectors/content' import { makeSelectClaimForUri, } from 'selectors/claims' import UriIndicator from './view' const makeSelect = () => { - const selectClaimForUri = makeSelectClaimForUri() + const selectClaim = makeSelectClaimForUri(), + selectIsResolving = makeSelectIsResolvingForUri(); const select = (state, props) => ({ - claim: selectClaimForUri(state, props), + claim: selectClaim(state, props), + isResolvingUri: selectIsResolving(state, props), + uri: lbryuri.normalize(props.uri), }) return select } -export default connect(makeSelect, null)(UriIndicator) +const perform = (dispatch) => ({ + resolveUri: (uri) => dispatch(doResolveUri(uri)) +}) + +export default connect(makeSelect, perform)(UriIndicator) diff --git a/ui/js/component/uriIndicator/view.jsx b/ui/js/component/uriIndicator/view.jsx index 36486578f..613ffec43 100644 --- a/ui/js/component/uriIndicator/view.jsx +++ b/ui/js/component/uriIndicator/view.jsx @@ -1,50 +1,74 @@ import React from 'react'; -import lbry from 'lbry'; -import lbryuri from 'lbryuri'; import {Icon} from 'component/common'; -const UriIndicator = (props) => { - const { - uri, - claim - } = props - - const uriObj = lbryuri.parse(uri); - - if (!claim) { - return Unused +class UriIndicator extends React.Component{ + componentWillMount() { + this.resolve(this.props) } - const { - has_signature: hasSignature, - signature_is_valid: signatureIsValid - } = claim - - if (!hasSignature || !uriObj.isChannel) { - return Anonymous; + componentWillReceiveProps(nextProps) { + this.resolve(nextProps) } - const channelUriObj = Object.assign({}, uriObj); - delete channelUriObj.path; - delete channelUriObj.contentName; - const channelUri = lbryuri.build(channelUriObj, false); + resolve(props) { + const { + isResolvingUri, + resolveUri, + claim, + uri, + } = props - let icon, modifier; - if (signatureIsValid) { - modifier = 'valid'; - } else { - icon = 'icon-times-circle'; - modifier = 'invalid'; + if(!isResolvingUri && claim === undefined && uri) { + resolveUri(uri) + } } - return ( - - {channelUri} {' '} - { !signatureIsValid ? - : - '' } - - ) + render() { + const { + claim, + uri, + isResolvingUri + } = this.props + + if (isResolvingUri) { + return Validating... + } + + if (!claim) { + return Unused + } + + const { + channel_name: channelName, + has_signature: hasSignature, + signature_is_valid: signatureIsValid, + } = claim + + console.log('uri indicator render') + console.log(uri) + console.log(claim) + + if (!hasSignature || !channelName) { + return Anonymous; + } + + let icon, modifier; + if (signatureIsValid) { + modifier = 'valid'; + } else { + icon = 'icon-times-circle'; + modifier = 'invalid'; + } + + return ( + + {channelName} {' '} + { !signatureIsValid ? + : + '' } + + ) + } } export default UriIndicator; \ No newline at end of file diff --git a/ui/js/page/channel/index.js b/ui/js/page/channel/index.js index 4ff8d8206..6ca94fdb1 100644 --- a/ui/js/page/channel/index.js +++ b/ui/js/page/channel/index.js @@ -11,8 +11,6 @@ import { } from 'selectors/claims' import ChannelPage from './view' -import FilePage from './view' - const makeSelect = () => { const selectClaim = makeSelectClaimForUri(), selectClaimsInChannel = makeSelectClaimsInChannelForUri() @@ -26,7 +24,6 @@ const makeSelect = () => { } const perform = (dispatch) => ({ - // fetchClaims: () => { console.log('fetch claims') } fetchClaims: (uri) => dispatch(doFetchClaimsByChannel(uri)) }) diff --git a/ui/js/page/channel/view.jsx b/ui/js/page/channel/view.jsx index 3caa59594..05b447c60 100644 --- a/ui/js/page/channel/view.jsx +++ b/ui/js/page/channel/view.jsx @@ -1,5 +1,7 @@ import React from 'react'; import lbryuri from 'lbryuri' +import {BusyMessage} from 'component/common' +import FileTile from 'component/fileTile' class ChannelPage extends React.Component{ componentDidMount() { @@ -23,7 +25,15 @@ class ChannelPage extends React.Component{ uri } = this.props - console.log(claimsInChannel); + let contentList + if (claimsInChannel === undefined) { + contentList = + } else if (claimsInChannel) { + contentList = claimsInChannel.length ? + claimsInChannel.map((claim) => ) : + No content found. + } + return
@@ -35,13 +45,8 @@ class ChannelPage extends React.Component{

-
-
- {claimsInChannel ? - claimsInChannel.map((claim) => ) - : ''} -
-
+

Published Content

+ {contentList}
} } diff --git a/ui/js/page/filePage/index.js b/ui/js/page/filePage/index.js index a8fee4d10..f61a3e803 100644 --- a/ui/js/page/filePage/index.js +++ b/ui/js/page/filePage/index.js @@ -2,6 +2,9 @@ import React from 'react' import { connect } from 'react-redux' +import { + doNavigate, +} from 'actions/app' import { doFetchFileInfo, } from 'actions/file_info' @@ -37,6 +40,7 @@ const makeSelect = () => { } const perform = (dispatch) => ({ + navigate: (path, params) => dispatch(doNavigate(path, params)), fetchFileInfo: (uri) => dispatch(doFetchFileInfo(uri)) }) diff --git a/ui/js/page/filePage/view.jsx b/ui/js/page/filePage/view.jsx index 72d95a276..2373588b7 100644 --- a/ui/js/page/filePage/view.jsx +++ b/ui/js/page/filePage/view.jsx @@ -74,6 +74,7 @@ class FilePage extends React.Component{ const { txid, nout, + channel_name: channelName, has_signature: hasSignature, signature_is_valid: signatureIsValid, value @@ -81,10 +82,8 @@ class FilePage extends React.Component{ const outpoint = txid + ':' + nout const title = metadata.title - const channelUriObj = lbryuri.parse(uri) - delete channelUriObj.path; - delete channelUriObj.contentName; - const channelUri = signatureIsValid && hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null + const channelClaimId = claim.value && claim.value.publisherSignature ? claim.value.publisherSignature.certificateId : null; + const channelUri = signatureIsValid && hasSignature && channelName ? lbryuri.build({channelName, claimId: channelClaimId}, false) : null const uriIndicator = return ( @@ -102,7 +101,7 @@ class FilePage extends React.Component{ : null}

{title}

{ channelUri ? - {uriIndicator} : + this.props.navigate('/show', { uri: channelUri })}>{uriIndicator} : uriIndicator}
diff --git a/ui/js/page/search/view.jsx b/ui/js/page/search/view.jsx index ac5486b12..8328434fc 100644 --- a/ui/js/page/search/view.jsx +++ b/ui/js/page/search/view.jsx @@ -8,8 +8,6 @@ import {BusyMessage} from 'component/common.js'; class SearchPage extends React.Component{ render() { - console.log('render search page') - const { query, } = this.props diff --git a/ui/js/page/settings/view.jsx b/ui/js/page/settings/view.jsx index 0f0649bc2..d1a4f188c 100644 --- a/ui/js/page/settings/view.jsx +++ b/ui/js/page/settings/view.jsx @@ -105,7 +105,7 @@ class SettingsPage extends React.Component { name="download_directory" defaultValue={daemonSettings.download_directory} helper="LBRY downloads will be saved here." - onChange={this.onDownloadDirChange} /> + onChange={this.onDownloadDirChange.bind(this)} />
@@ -132,7 +132,7 @@ class SettingsPage extends React.Component { defaultValue={daemonSettings.max_upload} placeholder="10" className="form-field__input--inline" - onChange={this.onMaxUploadFieldChange} + onChange={this.onMaxUploadFieldChange.bind(this)} /> : '' @@ -160,7 +160,7 @@ class SettingsPage extends React.Component { defaultValue={daemonSettings.max_download} placeholder="10" className="form-field__input--inline" - onChange={this.onMaxDownloadFieldChange} + onChange={this.onMaxDownloadFieldChange.bind(this)} /> : '' @@ -175,13 +175,13 @@ class SettingsPage extends React.Component {
@@ -191,7 +191,7 @@ class SettingsPage extends React.Component {
diff --git a/ui/js/page/showPage/view.jsx b/ui/js/page/showPage/view.jsx index 96983139c..bab2d4426 100644 --- a/ui/js/page/showPage/view.jsx +++ b/ui/js/page/showPage/view.jsx @@ -49,7 +49,7 @@ class ShowPage extends React.Component{ } else if (claim.name.length && claim.name[0] === '@') { - innerContent = + innerContent = } else if (claim) { innerContent = diff --git a/ui/js/reducers/claims.js b/ui/js/reducers/claims.js index 6acf0f111..7105a0d33 100644 --- a/ui/js/reducers/claims.js +++ b/ui/js/reducers/claims.js @@ -57,6 +57,22 @@ reducers[types.CLAIM_LIST_MINE_COMPLETED] = function(state, action) { }) } +// reducers[types.FETCH_CHANNEL_CLAIMS_STARTED] = function(state, action) { +// const { +// uri, +// } = action.data +// +// const newClaims = Object.assign({}, state.claimsByChannel) +// +// if (claims !== undefined) { +// newClaims[uri] = claims +// } +// +// return Object.assign({}, state, { +// claimsByChannel: newClaims +// }) +// } + reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) { const { uri,