some progress towards cost and file info refactor, plus other fixes
This commit is contained in:
parent
3fa4d0dfe7
commit
900c5cbc2b
22 changed files with 274 additions and 419 deletions
|
@ -57,66 +57,9 @@ export function doResolveUri(uri) {
|
|||
export function doCancelResolveUri(uri) {
|
||||
return function(dispatch, getState) {
|
||||
lbry.cancelResolve({ uri })
|
||||
}
|
||||
}
|
||||
|
||||
export function doFetchDownloadedContent() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState()
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_DOWNLOADED_CONTENT_STARTED,
|
||||
})
|
||||
|
||||
lbry.claim_list_mine().then((myClaimInfos) => {
|
||||
lbry.file_list().then((fileInfos) => {
|
||||
const myClaimOutpoints = myClaimInfos.map(({txid, nout}) => txid + ':' + nout);
|
||||
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const uri = lbryuri.build({
|
||||
channelName: fileInfo.channel_name,
|
||||
contentName: fileInfo.name,
|
||||
})
|
||||
const claim = selectClaimsByUri(state)[uri]
|
||||
if (!claim) dispatch(doResolveUri(uri))
|
||||
})
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_DOWNLOADED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
fileInfos: fileInfos.filter(({outpoint}) => !myClaimOutpoints.includes(outpoint)),
|
||||
}
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function doFetchPublishedContent() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState()
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_PUBLISHED_CONTENT_STARTED,
|
||||
})
|
||||
|
||||
lbry.claim_list_mine().then((claimInfos) => {
|
||||
dispatch({
|
||||
type: types.FETCH_MY_CLAIMS_COMPLETED,
|
||||
data: {
|
||||
claims: claimInfos,
|
||||
}
|
||||
})
|
||||
lbry.file_list().then((fileInfos) => {
|
||||
const myClaimOutpoints = claimInfos.map(({txid, nout}) => txid + ':' + nout)
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_PUBLISHED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
fileInfos: fileInfos.filter(({outpoint}) => myClaimOutpoints.includes(outpoint)),
|
||||
}
|
||||
})
|
||||
})
|
||||
type: types.RESOLVE_URI_CANCELED,
|
||||
data: { uri }
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -142,10 +85,18 @@ export function doFetchFeaturedUris() {
|
|||
dispatch({
|
||||
type: types.FETCH_FEATURED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
categories: Categories,
|
||||
uris: featuredUris,
|
||||
categories: ["FOO"],
|
||||
uris: { FOO: ["lbry://gtasoc"]},
|
||||
}
|
||||
})
|
||||
|
||||
// dispatch({
|
||||
// type: types.FETCH_FEATURED_CONTENT_COMPLETED,
|
||||
// data: {
|
||||
// categories: Categories,
|
||||
// uris: featuredUris,
|
||||
// }
|
||||
// })
|
||||
}
|
||||
|
||||
const failure = () => {
|
||||
|
@ -182,6 +133,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
|||
type: types.DOWNLOADING_COMPLETED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
}
|
||||
})
|
||||
|
@ -197,6 +149,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
|||
type: types.DOWNLOADING_PROGRESSED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
progress,
|
||||
}
|
||||
|
@ -216,6 +169,7 @@ export function doDownloadFile(uri, streamInfo) {
|
|||
type: types.DOWNLOADING_STARTED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint: streamInfo.outpoint,
|
||||
fileInfo,
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
import * as types from 'constants/action_types'
|
||||
import lbry from 'lbry'
|
||||
import lbryio from 'lbryio'
|
||||
import {
|
||||
doResolveUri
|
||||
} from 'actions/content'
|
||||
import {
|
||||
selectResolvingUris,
|
||||
} from 'selectors/content'
|
||||
import {
|
||||
selectClaimsByUri
|
||||
} from 'selectors/claims'
|
||||
|
@ -12,21 +18,23 @@ export function doFetchCostInfoForUri(uri) {
|
|||
return function(dispatch, getState) {
|
||||
const state = getState(),
|
||||
claim = selectClaimsByUri(state)[uri],
|
||||
isResolving = selectResolvingUris(state).indexOf(uri) !== -1,
|
||||
isGenerous = selectSettingsIsGenerous(state)
|
||||
|
||||
//
|
||||
// function getCostGenerous(uri) {
|
||||
// console.log('get cost generous: ' + 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) => {
|
||||
// console.log('resolve inside getCostGenerous ' + uri)
|
||||
// console.log(resolutionInfo)
|
||||
// if (!resolutionInfo) {
|
||||
// return reject(new Error("Unused URI"));
|
||||
// }
|
||||
if (claim === null) { //claim doesn't exist, nothing to fetch a cost for
|
||||
return
|
||||
}
|
||||
|
||||
if (!claim) {
|
||||
setTimeout(() => {
|
||||
dispatch(doFetchCostInfoForUri(uri))
|
||||
}, 1000)
|
||||
if (!isResolving) {
|
||||
dispatch(doResolveUri(uri))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// });
|
||||
// }
|
||||
|
||||
function begin() {
|
||||
dispatch({
|
||||
|
|
|
@ -4,6 +4,8 @@ import {
|
|||
selectClaimsByUri,
|
||||
} from 'selectors/claims'
|
||||
import {
|
||||
selectIsFileListPending,
|
||||
selectAllFileInfos,
|
||||
selectLoadingByUri,
|
||||
} from 'selectors/file_info'
|
||||
import {
|
||||
|
@ -25,7 +27,6 @@ export function doFetchFileInfo(uri) {
|
|||
dispatch({
|
||||
type: types.FETCH_FILE_INFO_STARTED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint,
|
||||
}
|
||||
})
|
||||
|
@ -34,7 +35,7 @@ export function doFetchFileInfo(uri) {
|
|||
dispatch({
|
||||
type: types.FETCH_FILE_INFO_COMPLETED,
|
||||
data: {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
}
|
||||
})
|
||||
|
@ -43,6 +44,28 @@ export function doFetchFileInfo(uri) {
|
|||
}
|
||||
}
|
||||
|
||||
export function doFileList(uri) {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState()
|
||||
const isPending = selectIsFileListPending(state)
|
||||
|
||||
if (!isPending) {
|
||||
dispatch({
|
||||
type: types.FILE_LIST_STARTED,
|
||||
})
|
||||
|
||||
lbry.file_list().then((fileInfos) => {
|
||||
dispatch({
|
||||
type: types.FILE_LIST_COMPLETED,
|
||||
data: {
|
||||
fileInfos,
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function doOpenFileInShell(fileInfo) {
|
||||
return function(dispatch, getState) {
|
||||
shell.openItem(fileInfo.download_path)
|
||||
|
@ -80,26 +103,56 @@ export function doDeleteFile(uri, fileInfo, deleteFromComputer) {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
export function doFetchDownloadedContent() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState()
|
||||
const state = getState(),
|
||||
fileInfos = selectAllFileInfos(state)
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_DOWNLOADED_CONTENT_STARTED,
|
||||
})
|
||||
|
||||
lbry.claim_list_mine().then((myClaimInfos) => {
|
||||
lbry.file_list().then((fileInfos) => {
|
||||
const myClaimOutpoints = myClaimInfos.map(({txid, nout}) => txid + ':' + nout);
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_DOWNLOADED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
fileInfos: fileInfos.filter(({outpoint}) => !myClaimOutpoints.includes(outpoint)),
|
||||
}
|
||||
})
|
||||
});
|
||||
const myClaimOutpoints = myClaimInfos.map(({txid, nout}) => txid + ':' + nout);
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_DOWNLOADED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
fileInfos: fileInfos.filter(({outpoint}) => !myClaimOutpoints.includes(outpoint)),
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function doFetchPublishedContent() {
|
||||
return function(dispatch, getState) {
|
||||
const state = getState(),
|
||||
fileInfos = selectAllFileInfos(state)
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_PUBLISHED_CONTENT_STARTED,
|
||||
})
|
||||
|
||||
lbry.claim_list_mine().then((claimInfos) => {
|
||||
dispatch({
|
||||
type: types.FETCH_MY_CLAIMS_COMPLETED,
|
||||
data: {
|
||||
claims: claimInfos,
|
||||
}
|
||||
})
|
||||
|
||||
const myClaimOutpoints = claimInfos.map(({txid, nout}) => txid + ':' + nout)
|
||||
|
||||
dispatch({
|
||||
type: types.FETCH_PUBLISHED_CONTENT_COMPLETED,
|
||||
data: {
|
||||
fileInfos: fileInfos.filter(({outpoint}) => myClaimOutpoints.includes(outpoint)),
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -200,7 +200,7 @@ const CodeRequiredStage = React.createClass({
|
|||
})
|
||||
|
||||
if (!this.state.address) {
|
||||
lbry.getUnusedAddress((address) => {
|
||||
lbry.wallet_unused_address().then((address) => {
|
||||
setLocal('wallet_address', address);
|
||||
this.setState({ address: address });
|
||||
});
|
||||
|
|
|
@ -72,9 +72,6 @@ class FileActions extends React.Component {
|
|||
|
||||
let content
|
||||
|
||||
console.log('file actions render')
|
||||
console.log(this.props)
|
||||
|
||||
if (!fileInfo && isAvailable === undefined) {
|
||||
|
||||
content = <BusyMessage message="Checking availability" />
|
||||
|
|
|
@ -34,7 +34,6 @@ const makeSelect = () => {
|
|||
claim: selectClaimForUri(state, props),
|
||||
fileInfo: selectFileInfoForUri(state, props),
|
||||
obscureNsfw: selectObscureNsfw(state),
|
||||
hasSignature: false,
|
||||
metadata: selectMetadataForUri(state, props),
|
||||
isResolvingUri: selectResolvingUri(state, props),
|
||||
})
|
||||
|
|
|
@ -2,12 +2,12 @@ import React from 'react';
|
|||
import lbry from 'lbry.js';
|
||||
import lbryuri from 'lbryuri.js';
|
||||
import Link from 'component/link';
|
||||
import {Thumbnail, TruncatedText,} from 'component/common';
|
||||
import {Thumbnail, TruncatedText, Icon} from 'component/common';
|
||||
import FilePrice from 'component/filePrice'
|
||||
import UriIndicator from 'component/uriIndicator';
|
||||
|
||||
class FileCard extends React.Component {
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
this.resolve(this.props)
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,15 @@ class FileCard extends React.Component {
|
|||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.cancelResolveUri(this.props.uri)
|
||||
const {
|
||||
isResolvingUri,
|
||||
cancelResolveUri,
|
||||
uri
|
||||
} = this.props
|
||||
|
||||
if (isResolvingUri) {
|
||||
cancelResolveUri(uri)
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseOver() {
|
||||
|
@ -47,6 +55,8 @@ class FileCard extends React.Component {
|
|||
render() {
|
||||
|
||||
const {
|
||||
claim,
|
||||
fileInfo,
|
||||
metadata,
|
||||
isResolvingUri,
|
||||
navigate,
|
||||
|
@ -61,6 +71,8 @@ class FileCard extends React.Component {
|
|||
description = "Loading..."
|
||||
} else if (metadata && metadata.description) {
|
||||
description = metadata.description
|
||||
} else if (claim === null) {
|
||||
description = 'This address contains no content.'
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -70,7 +82,10 @@ class FileCard extends React.Component {
|
|||
<div className="card__title-identity">
|
||||
<h5 title={title}><TruncatedText lines={1}>{title}</TruncatedText></h5>
|
||||
<div className="card__subtitle">
|
||||
{ !isResolvingUri && <span style={{float: "right"}}><FilePrice uri={uri} /></span> }
|
||||
<span style={{float: "right"}}>
|
||||
<FilePrice uri={uri} />
|
||||
{ fileInfo ? <span>{' '}<Icon fixed icon="icon-folder" /></span> : '' }
|
||||
</span>
|
||||
<UriIndicator uri={uri} />
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -12,6 +12,7 @@ import FilePrice from './view'
|
|||
|
||||
const makeSelect = () => {
|
||||
const selectCostInfoForUri = makeSelectCostInfoForUri()
|
||||
|
||||
const select = (state, props) => ({
|
||||
costInfo: selectCostInfoForUri(state, props),
|
||||
})
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
} from 'component/common'
|
||||
|
||||
class FilePrice extends React.Component{
|
||||
componentDidMount() {
|
||||
componentWillMount() {
|
||||
this.fetchCost(this.props)
|
||||
}
|
||||
|
||||
|
|
|
@ -13,11 +13,8 @@ class FileTile extends React.Component {
|
|||
|
||||
constructor(props) {
|
||||
super(props)
|
||||
this._fileInfoSubscribeId = null
|
||||
this._isMounted = null
|
||||
this.state = {
|
||||
showNsfwHelp: false,
|
||||
isHidden: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,31 +26,11 @@ class FileTile extends React.Component {
|
|||
uri,
|
||||
} = this.props
|
||||
|
||||
this._isMounted = true;
|
||||
|
||||
if (this.props.hideOnRemove) {
|
||||
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate);
|
||||
}
|
||||
|
||||
if(!isResolvingUri && !claim && uri) {
|
||||
resolveUri(uri)
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._fileInfoSubscribeId) {
|
||||
lbry.fileInfoUnsubscribe(this.props.outpoint, this._fileInfoSubscribeId);
|
||||
}
|
||||
}
|
||||
|
||||
onFileInfoUpdate(fileInfo) {
|
||||
if (!fileInfo && this._isMounted && this.props.hideOnRemove) {
|
||||
this.setState({
|
||||
isHidden: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
handleMouseOver() {
|
||||
if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) {
|
||||
this.setState({
|
||||
|
@ -71,10 +48,6 @@ class FileTile extends React.Component {
|
|||
}
|
||||
|
||||
render() {
|
||||
if (this.state.isHidden) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const {
|
||||
claim,
|
||||
metadata,
|
||||
|
|
|
@ -11,7 +11,7 @@ class VideoPlayButton extends React.Component {
|
|||
}
|
||||
|
||||
onWatchClick() {
|
||||
console.log(this.props)
|
||||
console.log(this)
|
||||
this.props.purchaseUri(this.props.uri).then(() => {
|
||||
if (!this.props.modal) {
|
||||
this.props.startPlaying()
|
||||
|
@ -24,7 +24,6 @@ class VideoPlayButton extends React.Component {
|
|||
button,
|
||||
label,
|
||||
className,
|
||||
onWatchClick,
|
||||
metadata,
|
||||
metadata: {
|
||||
title,
|
||||
|
@ -51,7 +50,7 @@ class VideoPlayButton extends React.Component {
|
|||
label={label ? label : ""}
|
||||
className="video__play-button"
|
||||
icon="icon-play"
|
||||
onClick={this.onWatchClick} />
|
||||
onClick={this.onWatchClick.bind(this)} />
|
||||
{modal}
|
||||
<Modal contentLabel="Not enough credits" isOpen={modal == 'notEnoughCredits'} onConfirmed={closeModal}>
|
||||
You don't have enough LBRY credits to pay for this stream.
|
||||
|
@ -142,11 +141,9 @@ class VideoPlayer extends React.Component {
|
|||
poster,
|
||||
} = this.props
|
||||
|
||||
//<source src={downloadPath} type={contentType} />
|
||||
|
||||
return (
|
||||
<video controls id="video" ref="video" style={{backgroundImage: "url('" + poster + "')"}} >
|
||||
|
||||
<source src={downloadPath} type={contentType} />
|
||||
</video>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -35,8 +35,11 @@ export const FETCH_FEATURED_CONTENT_STARTED = 'FETCH_FEATURED_CONTENT_STARTED'
|
|||
export const FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED'
|
||||
export const RESOLVE_URI_STARTED = 'RESOLVE_URI_STARTED'
|
||||
export const RESOLVE_URI_COMPLETED = 'RESOLVE_URI_COMPLETED'
|
||||
export const RESOLVE_URI_CANCELED = 'RESOLVE_URI_CANCELED'
|
||||
export const FETCH_CHANNEL_CLAIMS_STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED'
|
||||
export const FETCH_CHANNEL_CLAIMS_COMPLETED = 'FETCH_CHANNEL_CLAIMS_COMPLETED'
|
||||
export const FILE_LIST_STARTED = 'FILE_LIST_STARTED'
|
||||
export const FILE_LIST_COMPLETED = 'FILE_LIST_COMPLETED'
|
||||
export const FETCH_DOWNLOADED_CONTENT_STARTED = 'FETCH_DOWNLOADED_CONTENT_STARTED'
|
||||
export const FETCH_DOWNLOADED_CONTENT_COMPLETED = 'FETCH_DOWNLOADED_CONTENT_COMPLETED'
|
||||
export const FETCH_PUBLISHED_CONTENT_STARTED = 'FETCH_PUBLISHED_CONTENT_STARTED'
|
||||
|
|
157
ui/js/lbry.js
157
ui/js/lbry.js
|
@ -151,14 +151,6 @@ lbry.isDaemonAcceptingConnections = function (callback) {
|
|||
lbry.call('status', {}, () => callback(true), null, () => callback(false))
|
||||
};
|
||||
|
||||
lbry.checkFirstRun = function(callback) {
|
||||
lbry.call('is_first_run', {}, callback);
|
||||
}
|
||||
|
||||
lbry.getUnusedAddress = function(callback) {
|
||||
lbry.call('wallet_unused_address', {}, callback);
|
||||
}
|
||||
|
||||
lbry.checkAddressIsMine = function(address, callback) {
|
||||
lbry.call('address_is_mine', {address: address}, callback);
|
||||
}
|
||||
|
@ -167,108 +159,12 @@ lbry.sendToAddress = function(amount, address, callback, errorCallback) {
|
|||
lbry.call("send_amount_to_address", { "amount" : amount, "address": address }, callback, errorCallback);
|
||||
}
|
||||
|
||||
lbry.getClaimInfo = function(name, callback) {
|
||||
if (!name) {
|
||||
throw new Error(`Name required.`);
|
||||
}
|
||||
lbry.call('get_claim_info', { name: name }, callback);
|
||||
}
|
||||
|
||||
lbry.getMyClaim = function(name, callback) {
|
||||
lbry.call('claim_list_mine', {}, (claims) => {
|
||||
callback(claims.find((claim) => claim.name == name) || null);
|
||||
});
|
||||
}
|
||||
|
||||
lbry.getPeersForBlobHash = function(blobHash, callback) {
|
||||
let timedOut = false;
|
||||
const timeout = setTimeout(() => {
|
||||
timedOut = true;
|
||||
callback([]);
|
||||
}, lbry.peerListTimeout);
|
||||
|
||||
lbry.call('peer_list', { blob_hash: blobHash }, function(peers) {
|
||||
if (!timedOut) {
|
||||
clearTimeout(timeout);
|
||||
callback(peers);
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
// lbry.costPromiseCache = {}
|
||||
// lbry.getCostInfo = function(uri) {
|
||||
// if (lbry.costPromiseCache[uri] === undefined) {
|
||||
// lbry.costPromiseCache[uri] = new Promise((resolve, reject) => {
|
||||
// const COST_INFO_CACHE_KEY = 'cost_info_cache';
|
||||
// let costInfoCache = getSession(COST_INFO_CACHE_KEY, {})
|
||||
//
|
||||
// function cacheAndResolve(cost, includesData) {
|
||||
// console.log('getCostInfo cacheAndResolve ' + uri)
|
||||
// console.log(cost)
|
||||
// costInfoCache[uri] = {cost, includesData};
|
||||
// setSession(COST_INFO_CACHE_KEY, costInfoCache);
|
||||
// resolve({cost, includesData});
|
||||
// }
|
||||
//
|
||||
// if (!uri) {
|
||||
// return reject(new Error(`URI required.`));
|
||||
// }
|
||||
//
|
||||
// if (costInfoCache[uri] && costInfoCache[uri].cost) {
|
||||
// return resolve(costInfoCache[uri])
|
||||
// }
|
||||
//
|
||||
// function getCost(uri, size) {
|
||||
// lbry.stream_cost_estimate({uri, ... size !== null ? {size} : {}}).then((cost) => {
|
||||
// cacheAndResolve(cost, size !== null);
|
||||
// }, reject);
|
||||
// }
|
||||
//
|
||||
// function getCostGenerous(uri) {
|
||||
// console.log('get cost generous: ' + 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) => {
|
||||
// console.log('resolve inside getCostGenerous ' + uri)
|
||||
// console.log(resolutionInfo)
|
||||
// if (!resolutionInfo) {
|
||||
// return reject(new Error("Unused URI"));
|
||||
// }
|
||||
// const fee = resolutionInfo.claim.value.stream.metadata.fee;
|
||||
// if (fee === undefined) {
|
||||
// cacheAndResolve(0, true);
|
||||
// } else if (fee.currency == 'LBC') {
|
||||
// cacheAndResolve(fee.amount, true);
|
||||
// } else {
|
||||
// lbryio.getExchangeRates().then(({lbc_usd}) => {
|
||||
// cacheAndResolve(fee.amount / lbc_usd, true);
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// const uriObj = lbryuri.parse(uri);
|
||||
// const name = uriObj.path || uriObj.name;
|
||||
//
|
||||
// lbry.settings_get({allow_cached: true}).then(({is_generous_host}) => {
|
||||
// if (is_generous_host) {
|
||||
// return getCostGenerous(uri);
|
||||
// }
|
||||
//
|
||||
// lighthouse.get_size_for_name(name).then((size) => {
|
||||
// if (size) {
|
||||
// getCost(name, size);
|
||||
// }
|
||||
// else {
|
||||
// getCost(name, null);
|
||||
// }
|
||||
// }, () => {
|
||||
// getCost(name, null);
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
// return lbry.costPromiseCache[uri];
|
||||
// }
|
||||
/**
|
||||
* Takes a LBRY URI; will first try and calculate a total cost using
|
||||
* Lighthouse. If Lighthouse can't be reached, it just retrives the
|
||||
|
@ -287,8 +183,6 @@ lbry.getCostInfo = function(uri) {
|
|||
let costInfoCache = getSession(COST_INFO_CACHE_KEY, {})
|
||||
|
||||
function cacheAndResolve(cost, includesData) {
|
||||
console.log('getCostInfo cacheAndResolve ' + uri)
|
||||
console.log(cost)
|
||||
costInfoCache[uri] = {cost, includesData};
|
||||
setSession(COST_INFO_CACHE_KEY, costInfoCache);
|
||||
resolve({cost, includesData});
|
||||
|
@ -509,10 +403,7 @@ lbry.stop = function(callback) {
|
|||
lbry.call('stop', {}, callback);
|
||||
};
|
||||
|
||||
lbry.fileInfo = {};
|
||||
lbry._subscribeIdCount = 0;
|
||||
lbry._fileInfoSubscribeCallbacks = {};
|
||||
lbry._fileInfoSubscribeInterval = 500000;
|
||||
lbry._balanceSubscribeCallbacks = {};
|
||||
lbry._balanceSubscribeInterval = 5000;
|
||||
lbry._removedFiles = [];
|
||||
|
@ -527,54 +418,6 @@ lbry._updateClaimOwnershipCache = function(claimId) {
|
|||
|
||||
};
|
||||
|
||||
lbry._updateFileInfoSubscribers = function(outpoint) {
|
||||
const callSubscribedCallbacks = (outpoint, fileInfo) => {
|
||||
for (let callback of Object.values(this._fileInfoSubscribeCallbacks[outpoint])) {
|
||||
callback(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
if (lbry._removedFiles.includes(outpoint)) {
|
||||
callSubscribedCallbacks(outpoint, false);
|
||||
} else {
|
||||
lbry.file_list({
|
||||
outpoint: outpoint,
|
||||
full_status: true,
|
||||
}).then(([fileInfo]) => {
|
||||
if (fileInfo) {
|
||||
if (this._claimIdOwnershipCache[fileInfo.claim_id] === undefined) {
|
||||
this._updateClaimOwnershipCache(fileInfo.claim_id);
|
||||
}
|
||||
fileInfo.isMine = !!this._claimIdOwnershipCache[fileInfo.claim_id];
|
||||
}
|
||||
|
||||
callSubscribedCallbacks(outpoint, fileInfo);
|
||||
});
|
||||
}
|
||||
|
||||
if (Object.keys(this._fileInfoSubscribeCallbacks[outpoint]).length) {
|
||||
setTimeout(() => {
|
||||
this._updateFileInfoSubscribers(outpoint);
|
||||
}, lbry._fileInfoSubscribeInterval);
|
||||
}
|
||||
}
|
||||
|
||||
lbry.fileInfoSubscribe = function(outpoint, callback) {
|
||||
if (!lbry._fileInfoSubscribeCallbacks[outpoint])
|
||||
{
|
||||
lbry._fileInfoSubscribeCallbacks[outpoint] = {};
|
||||
}
|
||||
|
||||
const subscribeId = ++lbry._subscribeIdCount;
|
||||
lbry._fileInfoSubscribeCallbacks[outpoint][subscribeId] = callback;
|
||||
lbry._updateFileInfoSubscribers(outpoint);
|
||||
return subscribeId;
|
||||
}
|
||||
|
||||
lbry.fileInfoUnsubscribe = function(outpoint, subscribeId) {
|
||||
delete lbry._fileInfoSubscribeCallbacks[outpoint][subscribeId];
|
||||
}
|
||||
|
||||
lbry._balanceUpdateInterval = null;
|
||||
lbry._updateBalanceSubscribers = function() {
|
||||
lbry.get_balance().then(function(balance) {
|
||||
|
|
|
@ -17,6 +17,9 @@ import {
|
|||
import {
|
||||
doFetchDaemonSettings
|
||||
} from 'actions/settings'
|
||||
import {
|
||||
doFileList
|
||||
} from 'actions/file_info'
|
||||
import parseQueryParams from 'util/query_params'
|
||||
|
||||
const {remote, ipcRenderer} = require('electron');
|
||||
|
@ -56,6 +59,7 @@ var init = function() {
|
|||
window.sessionStorage.setItem('loaded', 'y'); //once we've made it here once per session, we don't need to show splash again
|
||||
app.store.dispatch(doHistoryPush({}, "Discover", "/discover"))
|
||||
app.store.dispatch(doFetchDaemonSettings())
|
||||
app.store.dispatch(doFileList())
|
||||
ReactDOM.render(<Provider store={store}><div>{ lbryio.enabled ? <AuthOverlay/> : '' }<App /><SnackBar /></div></Provider>, canvas)
|
||||
}
|
||||
|
||||
|
|
|
@ -4,12 +4,10 @@ import {
|
|||
} from 'react-redux'
|
||||
import {
|
||||
doFetchDownloadedContent,
|
||||
} from 'actions/content'
|
||||
import {
|
||||
selectFetchingDownloadedContent,
|
||||
} from 'selectors/content'
|
||||
} from 'actions/file_info'
|
||||
import {
|
||||
selectDownloadedFileInfo,
|
||||
selectFetchingDownloadedContent,
|
||||
} from 'selectors/file_info'
|
||||
import {
|
||||
doNavigate,
|
||||
|
|
|
@ -100,7 +100,7 @@ var PublishPage = React.createClass({
|
|||
};
|
||||
|
||||
if (this.state.isFee) {
|
||||
lbry.getUnusedAddress((address) => {
|
||||
lbry.wallet_unused_address().then((address) => {
|
||||
metadata.fee = {};
|
||||
metadata.fee[this.state.feeCurrency] = {
|
||||
amount: parseFloat(this.state.feeAmount),
|
||||
|
|
|
@ -21,6 +21,8 @@ class ShowPage extends React.Component{
|
|||
uri,
|
||||
} = props
|
||||
|
||||
console.log('show page resolve ' + uri)
|
||||
console.log('isResolving: ' + isResolvingUri)
|
||||
if(!isResolvingUri && claim === undefined && uri) {
|
||||
resolveUri(uri)
|
||||
}
|
||||
|
|
|
@ -14,9 +14,7 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
|||
|
||||
const newClaims = Object.assign({}, state.claimsByUri)
|
||||
|
||||
if (claim !== undefined) {
|
||||
newClaims[uri] = claim
|
||||
}
|
||||
newClaims[uri] = claim
|
||||
|
||||
//This needs a sanity boost...
|
||||
if (certificate !== undefined && claim === undefined) {
|
||||
|
@ -32,6 +30,15 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
|||
})
|
||||
}
|
||||
|
||||
reducers[types.RESOLVE_URI_CANCELED] = function(state, action) {
|
||||
const uri = action.data.uri
|
||||
const newClaims = Object.assign({}, state.claimsByUri)
|
||||
delete newClaims[uri]
|
||||
return Object.assign({}, state, {
|
||||
claimsByUri: newClaims
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
|
|
|
@ -30,7 +30,7 @@ reducers[types.RESOLVE_URI_STARTED] = function(state, action) {
|
|||
|
||||
const oldResolving = state.resolvingUris || []
|
||||
const newResolving = Object.assign([], oldResolving)
|
||||
if (newResolving.indexOf(uri) == -1) newResolving.push(uri)
|
||||
if (newResolving.indexOf(uri) === -1) newResolving.push(uri)
|
||||
|
||||
return Object.assign({}, state, {
|
||||
resolvingUris: newResolving
|
||||
|
@ -48,51 +48,14 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
|||
...resolvingUris.slice(index + 1)
|
||||
]
|
||||
|
||||
const newState = Object.assign({}, state, {
|
||||
return Object.assign({}, state, {
|
||||
resolvingUris: newResolvingUris,
|
||||
})
|
||||
|
||||
return Object.assign({}, state, newState)
|
||||
}
|
||||
|
||||
reducers[types.FETCH_DOWNLOADED_CONTENT_STARTED] = function(state, action) {
|
||||
return Object.assign({}, state, {
|
||||
fetchingDownloadedContent: true,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_DOWNLOADED_CONTENT_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
fileInfos
|
||||
} = action.data
|
||||
const newDownloadedContent = Object.assign({}, state.downloadedContent, {
|
||||
fileInfos
|
||||
})
|
||||
|
||||
return Object.assign({}, state, {
|
||||
downloadedContent: newDownloadedContent,
|
||||
fetchingDownloadedContent: false,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_PUBLISHED_CONTENT_STARTED] = function(state, action) {
|
||||
return Object.assign({}, state, {
|
||||
fetchingPublishedContent: true,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_PUBLISHED_CONTENT_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
fileInfos
|
||||
} = action.data
|
||||
const newPublishedContent = Object.assign({}, state.publishedContent, {
|
||||
fileInfos
|
||||
})
|
||||
|
||||
return Object.assign({}, state, {
|
||||
publishedContent: newPublishedContent,
|
||||
fetchingPublishedContent: false,
|
||||
})
|
||||
reducers[types.RESOLVE_URI_CANCELED] = function(state, action) {
|
||||
return reducers[types.RESOLVE_URI_COMPLETED](state, action)
|
||||
}
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
|
|
|
@ -5,13 +5,35 @@ const reducers = {}
|
|||
const defaultState = {
|
||||
}
|
||||
|
||||
reducers[types.FILE_LIST_STARTED] = function(state, action) {
|
||||
return Object.assign({}, state, {
|
||||
isFileListPending: true,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FILE_LIST_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
fileInfos,
|
||||
} = action.data
|
||||
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
fileInfos.forEach((fileInfo) => {
|
||||
newFileInfos[fileInfo.outpoint] = fileInfo
|
||||
})
|
||||
|
||||
return Object.assign({}, state, {
|
||||
isFileListPending: false,
|
||||
fileInfos: newFileInfos
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_FILE_INFO_STARTED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
outpoint
|
||||
} = action.data
|
||||
const newFetching = Object.assign({}, state.fetching)
|
||||
|
||||
newFetching[uri] = true
|
||||
newFetching[outpoint] = true
|
||||
|
||||
return Object.assign({}, state, {
|
||||
fetching: newFetching,
|
||||
|
@ -20,19 +42,18 @@ reducers[types.FETCH_FILE_INFO_STARTED] = function(state, action) {
|
|||
|
||||
reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
fileInfo,
|
||||
outpoint,
|
||||
} = action.data
|
||||
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
const newFetching = Object.assign({}, state.fetching)
|
||||
|
||||
newByUri[uri] = fileInfo || null
|
||||
|
||||
delete newFetching[uri]
|
||||
newFileInfos[outpoint] = fileInfo
|
||||
delete newFetching[outpoint]
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byUri: newByUri,
|
||||
fileInfos: newFileInfos,
|
||||
fetching: newFetching,
|
||||
})
|
||||
}
|
||||
|
@ -40,9 +61,10 @@ reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
|||
reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
} = action.data
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
const newDownloading = Object.assign({}, state.downloading)
|
||||
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
||||
const newLoading = Object.assign({}, state.loading)
|
||||
|
@ -50,13 +72,13 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
|||
|
||||
newDownloadingByUri[uri] = true
|
||||
newDownloading.byUri = newDownloadingByUri
|
||||
newByUri[uri] = fileInfo
|
||||
newFileInfos[outpoint] = fileInfo
|
||||
delete newLoadingByUri[uri]
|
||||
newLoading.byUri = newLoadingByUri
|
||||
|
||||
return Object.assign({}, state, {
|
||||
downloading: newDownloading,
|
||||
byUri: newByUri,
|
||||
fileInfos: newFileInfos,
|
||||
loading: newLoading,
|
||||
})
|
||||
}
|
||||
|
@ -64,16 +86,17 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
|||
reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
} = action.data
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
const newDownloading = Object.assign({}, state.downloading)
|
||||
|
||||
newByUri[uri] = fileInfo
|
||||
newFileInfos[outpoint] = fileInfo
|
||||
newDownloading[uri] = true
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byUri: newByUri,
|
||||
fileInfos: newByUri,
|
||||
downloading: newDownloading
|
||||
})
|
||||
}
|
||||
|
@ -81,31 +104,32 @@ reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
|
|||
reducers[types.DOWNLOADING_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
outpoint,
|
||||
fileInfo,
|
||||
} = action.data
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
const newDownloading = Object.assign({}, state.downloading)
|
||||
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
||||
|
||||
newByUri[uri] = fileInfo
|
||||
newFileInfos[outpoint] = fileInfo
|
||||
delete newDownloadingByUri[uri]
|
||||
newDownloading.byUri = newDownloadingByUri
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byUri: newByUri,
|
||||
fileInfos: newFileInfos,
|
||||
downloading: newDownloading,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.DELETE_FILE_STARTED] = function(state, action) {
|
||||
const {
|
||||
uri,
|
||||
outpoint
|
||||
} = action.data
|
||||
const newDeleting = Object.assign({}, state.deleting)
|
||||
const newByUri = Object.assign({}, newDeleting.byUri)
|
||||
|
||||
newByUri[uri] = true
|
||||
newDeleting.byUri = newByUri
|
||||
newFileInfos[outpoint] = true
|
||||
newDeleting.byUri = newFileInfos
|
||||
|
||||
return Object.assign({}, state, {
|
||||
deleting: newDeleting,
|
||||
|
@ -118,15 +142,15 @@ reducers[types.DELETE_FILE_COMPLETED] = function(state, action) {
|
|||
} = action.data
|
||||
const newDeleting = Object.assign({}, state.deleting)
|
||||
const newDeletingByUri = Object.assign({}, newDeleting.byUri)
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
|
||||
delete newDeletingByUri[uri]
|
||||
newDeleting.byUri = newDeletingByUri
|
||||
delete newByUri[uri]
|
||||
delete newFileInfos[outpoint]
|
||||
|
||||
return Object.assign({}, state, {
|
||||
deleting: newDeleting,
|
||||
byUri: newByUri,
|
||||
fileInfos: newFileInfos,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -135,10 +159,10 @@ reducers[types.LOADING_VIDEO_STARTED] = function(state, action) {
|
|||
uri,
|
||||
} = action.data
|
||||
const newLoading = Object.assign({}, state.loading)
|
||||
const newByUri = Object.assign({}, newLoading.byUri)
|
||||
const newFileInfos = Object.assign({}, newLoading.byUri)
|
||||
|
||||
newByUri[uri] = true
|
||||
newLoading.byUri = newByUri
|
||||
newFileInfos[outpoint] = true
|
||||
newLoading.byUri = newFileInfos
|
||||
|
||||
return Object.assign({}, state, {
|
||||
loading: newLoading,
|
||||
|
@ -150,33 +174,38 @@ reducers[types.LOADING_VIDEO_FAILED] = function(state, action) {
|
|||
uri,
|
||||
} = action.data
|
||||
const newLoading = Object.assign({}, state.loading)
|
||||
const newByUri = Object.assign({}, newLoading.byUri)
|
||||
const newFileInfos = Object.assign({}, newLoading.byUri)
|
||||
|
||||
delete newByUri[uri]
|
||||
newLoading.byUri = newByUri
|
||||
delete newFileInfos[outpoint]
|
||||
newLoading.byUri = newFileInfos
|
||||
|
||||
return Object.assign({}, state, {
|
||||
loading: newLoading,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_DOWNLOADED_CONTENT_STARTED] = function(state, action) {
|
||||
return Object.assign({}, state, {
|
||||
fetchingDownloadedContent: true,
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_DOWNLOADED_CONTENT_COMPLETED] = function(state, action) {
|
||||
const {
|
||||
fileInfos,
|
||||
} = action.data
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const uri = lbryuri.build({
|
||||
channelName: fileInfo.channel_name,
|
||||
contentName: fileInfo.name,
|
||||
})
|
||||
|
||||
newByUri[uri] = fileInfo
|
||||
action.data.fileInfos.forEach(fileInfo => {
|
||||
newFileInfos[fileInfo.outpoint] = fileInfo
|
||||
})
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byUri: newByUri
|
||||
fileInfos: newFileInfos,
|
||||
fetchingDownloadedContent: false
|
||||
})
|
||||
}
|
||||
|
||||
reducers[types.FETCH_PUBLISHED_CONTENT_STARTED] = function(state, action) {
|
||||
return Object.assign({}, state, {
|
||||
fetchingPublishedContent: true,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -184,23 +213,20 @@ reducers[types.FETCH_PUBLISHED_CONTENT_COMPLETED] = function(state, action) {
|
|||
const {
|
||||
fileInfos
|
||||
} = action.data
|
||||
const newByUri = Object.assign({}, state.byUri)
|
||||
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||
|
||||
fileInfos.forEach(fileInfo => {
|
||||
const uri = lbryuri.build({
|
||||
channelName: fileInfo.channel_name,
|
||||
contentName: fileInfo.name,
|
||||
})
|
||||
|
||||
newByUri[uri] = fileInfo
|
||||
newFileInfos[fileInfo.outpoint] = fileInfo
|
||||
})
|
||||
|
||||
return Object.assign({}, state, {
|
||||
byUri: newByUri
|
||||
fileInfos: newFileInfos,
|
||||
fetchingPublishedContent: false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default function reducer(state = defaultState, action) {
|
||||
const handler = reducers[action.type];
|
||||
if (handler) return handler(state, action);
|
||||
|
|
|
@ -16,32 +16,6 @@ export const selectFetchingFeaturedUris = createSelector(
|
|||
(state) => !!state.fetchingFeaturedContent
|
||||
)
|
||||
|
||||
|
||||
export const selectFetchingDownloadedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => !!state.fetchingDownloadedContent
|
||||
)
|
||||
|
||||
export const selectDownloadedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => state.downloadedContent || {}
|
||||
)
|
||||
|
||||
export const selectDownloadedContentFileInfos = createSelector(
|
||||
selectDownloadedContent,
|
||||
(downloadedContent) => downloadedContent.fileInfos || []
|
||||
)
|
||||
|
||||
export const selectFetchingPublishedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => !!state.fetchingPublishedContent
|
||||
)
|
||||
|
||||
export const selectPublishedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => state.publishedContent || {}
|
||||
)
|
||||
|
||||
export const selectResolvingUris = createSelector(
|
||||
_selectState,
|
||||
(state) => state.resolvingUris || []
|
||||
|
|
|
@ -2,14 +2,20 @@ import {
|
|||
createSelector,
|
||||
} from 'reselect'
|
||||
import {
|
||||
selectClaimsByUri,
|
||||
selectMyClaimsOutpoints,
|
||||
} from 'selectors/claims'
|
||||
|
||||
export const _selectState = state => state.fileInfo || {}
|
||||
|
||||
export const selectAllFileInfoByUri = createSelector(
|
||||
export const selectIsFileListPending = createSelector(
|
||||
_selectState,
|
||||
(state) => state.byUri || {}
|
||||
(state) => state.isFileListPending
|
||||
)
|
||||
|
||||
export const selectAllFileInfos = createSelector(
|
||||
_selectState,
|
||||
(state) => state.fileInfos || {}
|
||||
)
|
||||
|
||||
export const selectDownloading = createSelector(
|
||||
|
@ -22,8 +28,42 @@ export const selectDownloadingByUri = createSelector(
|
|||
(downloading) => downloading.byUri || {}
|
||||
)
|
||||
|
||||
export const selectFetchingDownloadedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => !!state.fetchingDownloadedContent
|
||||
)
|
||||
|
||||
export const selectDownloadedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => state.downloadedContent || {}
|
||||
)
|
||||
|
||||
export const selectDownloadedContentFileInfos = createSelector(
|
||||
selectDownloadedContent,
|
||||
(downloadedContent) => downloadedContent.fileInfos || []
|
||||
)
|
||||
|
||||
export const selectFetchingPublishedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => !!state.fetchingPublishedContent
|
||||
)
|
||||
|
||||
export const selectPublishedContent = createSelector(
|
||||
_selectState,
|
||||
(state) => state.publishedContent || {}
|
||||
)
|
||||
|
||||
export const selectFileInfoForUri = (state, props) => {
|
||||
return selectAllFileInfoByUri(state)[props.uri]
|
||||
const claims = selectClaimsByUri(state),
|
||||
claim = claims[props.uri],
|
||||
outpoint = claim ? `${claim.txid}:${claim.nout}` : undefined
|
||||
|
||||
console.log('select file info')
|
||||
console.log(claims)
|
||||
console.log(claim)
|
||||
console.log(outpoint)
|
||||
console.log(selectAllFileInfos(state))
|
||||
return outpoint ? selectAllFileInfos(state)[outpoint] : undefined
|
||||
}
|
||||
|
||||
export const makeSelectFileInfoForUri = () => {
|
||||
|
@ -68,23 +108,21 @@ export const makeSelectLoadingForUri = () => {
|
|||
}
|
||||
|
||||
export const selectDownloadedFileInfo = createSelector(
|
||||
selectAllFileInfoByUri,
|
||||
(byUri) => {
|
||||
selectAllFileInfos,
|
||||
(fileInfos) => {
|
||||
const fileInfoList = []
|
||||
Object.keys(byUri).forEach(key => {
|
||||
const fileInfo = byUri[key]
|
||||
|
||||
Object.keys(fileInfos).forEach(outpoint => {
|
||||
const fileInfo = fileInfos[outpoint]
|
||||
if (fileInfo.completed || fileInfo.written_bytes) {
|
||||
fileInfoList.push(fileInfo)
|
||||
}
|
||||
})
|
||||
|
||||
return fileInfoList
|
||||
}
|
||||
)
|
||||
|
||||
export const selectPublishedFileInfo = createSelector(
|
||||
selectAllFileInfoByUri,
|
||||
selectAllFileInfos,
|
||||
selectMyClaimsOutpoints,
|
||||
(byUri, outpoints) => {
|
||||
const fileInfos = []
|
||||
|
|
Loading…
Add table
Reference in a new issue