some progress but also broken show
This commit is contained in:
parent
1dedb9873c
commit
d517316554
10 changed files with 93 additions and 66 deletions
|
@ -28,6 +28,7 @@ export function doNavigate(path, params = {}) {
|
|||
if (params)
|
||||
url = `${url}?${queryStringFromParams(params)}`
|
||||
|
||||
console.log('Path: ' + url);
|
||||
dispatch(doChangePath(url))
|
||||
|
||||
const state = getState()
|
||||
|
|
|
@ -44,7 +44,7 @@ export function doResolveUri(uri) {
|
|||
const {
|
||||
claim,
|
||||
certificate,
|
||||
} = resolutionInfo
|
||||
} = resolutionInfo ? resolutionInfo : { claim : null, certificate: null }
|
||||
|
||||
dispatch({
|
||||
type: types.RESOLVE_URI_COMPLETED,
|
||||
|
|
|
@ -21,7 +21,7 @@ export function doFetchCostInfoForUri(uri) {
|
|||
costInfo,
|
||||
}
|
||||
})
|
||||
})
|
||||
}).catch(() => {})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ class FileCard extends React.Component {
|
|||
<UriIndicator uri={uri} />
|
||||
</div>
|
||||
</div>
|
||||
{metadata &&
|
||||
{metadata && metadata.thumbnail &&
|
||||
<div className="card__media" style={{ backgroundImage: "url('" + metadata.thumbnail + "')" }}></div>
|
||||
}
|
||||
<div className="card__content card__subtext card__subtext--two-lines">
|
||||
|
|
|
@ -6,14 +6,20 @@ import {Icon} from 'component/common';
|
|||
const UriIndicator = (props) => {
|
||||
const {
|
||||
uri,
|
||||
claim: {
|
||||
has_signature: hasSignature,
|
||||
signature_is_valid: signatureIsValid,
|
||||
} = {},
|
||||
claim
|
||||
} = props
|
||||
|
||||
const uriObj = lbryuri.parse(uri);
|
||||
|
||||
if (!claim) {
|
||||
return <span className="empty">Unused</span>
|
||||
}
|
||||
|
||||
const {
|
||||
has_signature: hasSignature,
|
||||
signature_is_valid: signatureIsValid
|
||||
} = claim
|
||||
|
||||
if (!hasSignature || !uriObj.isChannel) {
|
||||
return <span className="empty">Anonymous</span>;
|
||||
}
|
||||
|
|
|
@ -254,6 +254,9 @@ lbry.getCostInfo = function(uri) {
|
|||
function getCostGenerous(uri) {
|
||||
// If generous is on, the calculation is simple enough that we might as well do it here in the front end
|
||||
lbry.resolve({uri: uri}).then((resolutionInfo) => {
|
||||
if (!resolutionInfo) {
|
||||
return reject(new Error("Unused URI"));
|
||||
}
|
||||
const fee = resolutionInfo.claim.value.stream.metadata.fee;
|
||||
if (fee === undefined) {
|
||||
cacheAndResolve(0, true);
|
||||
|
|
|
@ -2,6 +2,12 @@ import React from 'react'
|
|||
import {
|
||||
connect
|
||||
} from 'react-redux'
|
||||
import {
|
||||
doResolveUri,
|
||||
} from 'actions/content'
|
||||
import {
|
||||
doNavigate,
|
||||
} from 'actions/app'
|
||||
import {
|
||||
selectCurrentUri,
|
||||
} from 'selectors/app'
|
||||
|
@ -17,19 +23,27 @@ import {
|
|||
import {
|
||||
selectCurrentUriCostInfo,
|
||||
} from 'selectors/cost_info'
|
||||
import {
|
||||
makeSelectResolvingUri,
|
||||
} from 'selectors/content'
|
||||
import ShowPage from './view'
|
||||
|
||||
const select = (state) => ({
|
||||
const makeSelect = () => {
|
||||
const selectResolvingUri = makeSelectResolvingUri()
|
||||
|
||||
const select = (state, props) => ({
|
||||
claim: selectCurrentUriClaim(state),
|
||||
uri: selectCurrentUri(state),
|
||||
isDownloaded: selectCurrentUriIsDownloaded(state),
|
||||
fileInfo: selectCurrentUriFileInfo(state),
|
||||
costInfo: selectCurrentUriCostInfo(state),
|
||||
isFailed: false,
|
||||
isResolvingUri: selectResolvingUri(state, props),
|
||||
claimType: 'file',
|
||||
})
|
||||
})
|
||||
|
||||
return select
|
||||
}
|
||||
|
||||
const perform = (dispatch) => ({
|
||||
navigate: (path, params) => dispatch(doNavigate(path, params)),
|
||||
resolveUri: (uri) => dispatch(doResolveUri(uri)),
|
||||
})
|
||||
|
||||
export default connect(select, perform)(ShowPage)
|
||||
export default connect(makeSelect, perform)(ShowPage)
|
||||
|
|
|
@ -4,69 +4,63 @@ import {
|
|||
} from 'component/common';
|
||||
import FilePage from 'page/filePage'
|
||||
|
||||
const ShowPage = (props) => {
|
||||
class ShowPage extends React.Component{
|
||||
componentWillMount() {
|
||||
const {
|
||||
isResolvingUri,
|
||||
resolveUri,
|
||||
claim,
|
||||
navigate,
|
||||
claim: {
|
||||
txid,
|
||||
nout,
|
||||
has_signature: hasSignature,
|
||||
signature_is_valid: signatureIsValid,
|
||||
value,
|
||||
value: {
|
||||
stream,
|
||||
stream: {
|
||||
metadata,
|
||||
source,
|
||||
metadata: {
|
||||
title,
|
||||
} = {},
|
||||
source: {
|
||||
contentType,
|
||||
} = {},
|
||||
} = {},
|
||||
} = {},
|
||||
},
|
||||
uri,
|
||||
isDownloaded,
|
||||
fileInfo,
|
||||
costInfo,
|
||||
costInfo: {
|
||||
cost,
|
||||
includesData: costIncludesData,
|
||||
} = {},
|
||||
isFailed,
|
||||
claimType,
|
||||
} = props
|
||||
} = this.props
|
||||
|
||||
if(!isResolvingUri && !claim && uri) {
|
||||
resolveUri(uri)
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
claim: {
|
||||
value: {
|
||||
stream: {
|
||||
metadata
|
||||
} = {},
|
||||
} = {},
|
||||
} = {},
|
||||
navigate,
|
||||
uri,
|
||||
isResolvingUri,
|
||||
claimType,
|
||||
} = this.props
|
||||
|
||||
const outpoint = txid + ':' + nout;
|
||||
const uriLookupComplete = !!claim && Object.keys(claim).length
|
||||
const pageTitle = metadata ? metadata.title : uri;
|
||||
|
||||
let innerContent = "";
|
||||
|
||||
if (!uriLookupComplete || isFailed) {
|
||||
if (isResolvingUri) {
|
||||
innerContent = <section className="card">
|
||||
<div className="card__inner">
|
||||
<div className="card__title-identity"><h1>{pageTitle}</h1></div>
|
||||
</div>
|
||||
<div className="card__content">
|
||||
{ uriLookupComplete ?
|
||||
<p>This location is not yet in use. { ' ' }<Link onClick={() => navigate('/publish')} label="Put something here" />.</p> :
|
||||
<BusyMessage message="Loading magic decentralized data..." />
|
||||
{ isResolvingUri ?
|
||||
<BusyMessage message="Loading magic decentralized data..." /> :
|
||||
<p>This location is not yet in use. { ' ' }<Link onClick={() => navigate('/publish')} label="Put something here" />.</p>
|
||||
}
|
||||
</div>
|
||||
</section>;
|
||||
} else if (claimType == "channel") {
|
||||
}
|
||||
else if (claimType == "channel") {
|
||||
innerContent = <ChannelPage title={uri} />
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
innerContent = <FilePage uri={uri} />
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="main--single-column">{innerContent}</main>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export default ShowPage
|
||||
|
|
|
@ -16,12 +16,14 @@ export const selectClaimsByUri = createSelector(
|
|||
export const selectCurrentUriClaim = createSelector(
|
||||
selectCurrentUri,
|
||||
selectClaimsByUri,
|
||||
(uri, byUri) => byUri[uri] || {}
|
||||
(uri, byUri) => byUri[uri]
|
||||
)
|
||||
|
||||
export const selectCurrentUriClaimOutpoint = createSelector(
|
||||
selectCurrentUriClaim,
|
||||
(claim) => `${claim.txid}:${claim.nout}`
|
||||
(claim) => {
|
||||
return claim ? `${claim.txid}:${claim.nout}` : null
|
||||
}
|
||||
)
|
||||
|
||||
const selectClaimForUri = (state, props) => {
|
||||
|
|
|
@ -71,10 +71,17 @@ export const shouldFetchCurrentUriFileInfo = createSelector(
|
|||
selectFetchingCurrentUriFileInfo,
|
||||
selectCurrentUriFileInfo,
|
||||
(page, uri, fetching, fileInfo) => {
|
||||
console.log('should fetch?');
|
||||
console.log(page);
|
||||
console.log(uri);
|
||||
console.log(fetching);
|
||||
|
||||
if (page != 'show') return false
|
||||
if (fetching) return false
|
||||
if (fileInfo != undefined) return false
|
||||
|
||||
console.log('fetch!');
|
||||
|
||||
return true
|
||||
}
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue