mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-09-01 09:45:10 +00:00
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) {
|
export function doCancelResolveUri(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
lbry.cancelResolve({ uri })
|
lbry.cancelResolve({ uri })
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doFetchDownloadedContent() {
|
|
||||||
return function(dispatch, getState) {
|
|
||||||
const state = getState()
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_DOWNLOADED_CONTENT_STARTED,
|
type: types.RESOLVE_URI_CANCELED,
|
||||||
})
|
data: { uri }
|
||||||
|
|
||||||
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)),
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -142,10 +85,18 @@ export function doFetchFeaturedUris() {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_FEATURED_CONTENT_COMPLETED,
|
type: types.FETCH_FEATURED_CONTENT_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
categories: Categories,
|
categories: ["FOO"],
|
||||||
uris: featuredUris,
|
uris: { FOO: ["lbry://gtasoc"]},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// dispatch({
|
||||||
|
// type: types.FETCH_FEATURED_CONTENT_COMPLETED,
|
||||||
|
// data: {
|
||||||
|
// categories: Categories,
|
||||||
|
// uris: featuredUris,
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
const failure = () => {
|
const failure = () => {
|
||||||
|
@ -182,6 +133,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
type: types.DOWNLOADING_COMPLETED,
|
type: types.DOWNLOADING_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -197,6 +149,7 @@ export function doUpdateLoadStatus(uri, outpoint) {
|
||||||
type: types.DOWNLOADING_PROGRESSED,
|
type: types.DOWNLOADING_PROGRESSED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
progress,
|
progress,
|
||||||
}
|
}
|
||||||
|
@ -216,6 +169,7 @@ export function doDownloadFile(uri, streamInfo) {
|
||||||
type: types.DOWNLOADING_STARTED,
|
type: types.DOWNLOADING_STARTED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint: streamInfo.outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
import * as types from 'constants/action_types'
|
import * as types from 'constants/action_types'
|
||||||
import lbry from 'lbry'
|
import lbry from 'lbry'
|
||||||
import lbryio from 'lbryio'
|
import lbryio from 'lbryio'
|
||||||
|
import {
|
||||||
|
doResolveUri
|
||||||
|
} from 'actions/content'
|
||||||
|
import {
|
||||||
|
selectResolvingUris,
|
||||||
|
} from 'selectors/content'
|
||||||
import {
|
import {
|
||||||
selectClaimsByUri
|
selectClaimsByUri
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
|
@ -12,21 +18,23 @@ export function doFetchCostInfoForUri(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState(),
|
const state = getState(),
|
||||||
claim = selectClaimsByUri(state)[uri],
|
claim = selectClaimsByUri(state)[uri],
|
||||||
|
isResolving = selectResolvingUris(state).indexOf(uri) !== -1,
|
||||||
isGenerous = selectSettingsIsGenerous(state)
|
isGenerous = selectSettingsIsGenerous(state)
|
||||||
|
|
||||||
//
|
if (claim === null) { //claim doesn't exist, nothing to fetch a cost for
|
||||||
// function getCostGenerous(uri) {
|
return
|
||||||
// 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) => {
|
if (!claim) {
|
||||||
// console.log('resolve inside getCostGenerous ' + uri)
|
setTimeout(() => {
|
||||||
// console.log(resolutionInfo)
|
dispatch(doFetchCostInfoForUri(uri))
|
||||||
// if (!resolutionInfo) {
|
}, 1000)
|
||||||
// return reject(new Error("Unused URI"));
|
if (!isResolving) {
|
||||||
// }
|
dispatch(doResolveUri(uri))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
dispatch({
|
dispatch({
|
||||||
|
|
|
@ -4,6 +4,8 @@ import {
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import {
|
import {
|
||||||
|
selectIsFileListPending,
|
||||||
|
selectAllFileInfos,
|
||||||
selectLoadingByUri,
|
selectLoadingByUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
|
@ -25,7 +27,6 @@ export function doFetchFileInfo(uri) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_FILE_INFO_STARTED,
|
type: types.FETCH_FILE_INFO_STARTED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
|
||||||
outpoint,
|
outpoint,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -34,7 +35,7 @@ export function doFetchFileInfo(uri) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_FILE_INFO_COMPLETED,
|
type: types.FETCH_FILE_INFO_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
outpoint,
|
||||||
fileInfo,
|
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) {
|
export function doOpenFileInShell(fileInfo) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
shell.openItem(fileInfo.download_path)
|
shell.openItem(fileInfo.download_path)
|
||||||
|
@ -80,26 +103,56 @@ export function doDeleteFile(uri, fileInfo, deleteFromComputer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function doFetchDownloadedContent() {
|
export function doFetchDownloadedContent() {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState(),
|
||||||
|
fileInfos = selectAllFileInfos(state)
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_DOWNLOADED_CONTENT_STARTED,
|
type: types.FETCH_DOWNLOADED_CONTENT_STARTED,
|
||||||
})
|
})
|
||||||
|
|
||||||
lbry.claim_list_mine().then((myClaimInfos) => {
|
lbry.claim_list_mine().then((myClaimInfos) => {
|
||||||
lbry.file_list().then((fileInfos) => {
|
|
||||||
const myClaimOutpoints = myClaimInfos.map(({txid, nout}) => txid + ':' + nout);
|
|
||||||
|
|
||||||
dispatch({
|
const myClaimOutpoints = myClaimInfos.map(({txid, nout}) => txid + ':' + nout);
|
||||||
type: types.FETCH_DOWNLOADED_CONTENT_COMPLETED,
|
|
||||||
data: {
|
dispatch({
|
||||||
fileInfos: fileInfos.filter(({outpoint}) => !myClaimOutpoints.includes(outpoint)),
|
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) {
|
if (!this.state.address) {
|
||||||
lbry.getUnusedAddress((address) => {
|
lbry.wallet_unused_address().then((address) => {
|
||||||
setLocal('wallet_address', address);
|
setLocal('wallet_address', address);
|
||||||
this.setState({ address: address });
|
this.setState({ address: address });
|
||||||
});
|
});
|
||||||
|
|
|
@ -72,9 +72,6 @@ class FileActions extends React.Component {
|
||||||
|
|
||||||
let content
|
let content
|
||||||
|
|
||||||
console.log('file actions render')
|
|
||||||
console.log(this.props)
|
|
||||||
|
|
||||||
if (!fileInfo && isAvailable === undefined) {
|
if (!fileInfo && isAvailable === undefined) {
|
||||||
|
|
||||||
content = <BusyMessage message="Checking availability" />
|
content = <BusyMessage message="Checking availability" />
|
||||||
|
|
|
@ -34,7 +34,6 @@ const makeSelect = () => {
|
||||||
claim: selectClaimForUri(state, props),
|
claim: selectClaimForUri(state, props),
|
||||||
fileInfo: selectFileInfoForUri(state, props),
|
fileInfo: selectFileInfoForUri(state, props),
|
||||||
obscureNsfw: selectObscureNsfw(state),
|
obscureNsfw: selectObscureNsfw(state),
|
||||||
hasSignature: false,
|
|
||||||
metadata: selectMetadataForUri(state, props),
|
metadata: selectMetadataForUri(state, props),
|
||||||
isResolvingUri: selectResolvingUri(state, props),
|
isResolvingUri: selectResolvingUri(state, props),
|
||||||
})
|
})
|
||||||
|
|
|
@ -2,12 +2,12 @@ import React from 'react';
|
||||||
import lbry from 'lbry.js';
|
import lbry from 'lbry.js';
|
||||||
import lbryuri from 'lbryuri.js';
|
import lbryuri from 'lbryuri.js';
|
||||||
import Link from 'component/link';
|
import Link from 'component/link';
|
||||||
import {Thumbnail, TruncatedText,} from 'component/common';
|
import {Thumbnail, TruncatedText, Icon} from 'component/common';
|
||||||
import FilePrice from 'component/filePrice'
|
import FilePrice from 'component/filePrice'
|
||||||
import UriIndicator from 'component/uriIndicator';
|
import UriIndicator from 'component/uriIndicator';
|
||||||
|
|
||||||
class FileCard extends React.Component {
|
class FileCard extends React.Component {
|
||||||
componentDidMount() {
|
componentWillMount() {
|
||||||
this.resolve(this.props)
|
this.resolve(this.props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,15 @@ class FileCard extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.cancelResolveUri(this.props.uri)
|
const {
|
||||||
|
isResolvingUri,
|
||||||
|
cancelResolveUri,
|
||||||
|
uri
|
||||||
|
} = this.props
|
||||||
|
|
||||||
|
if (isResolvingUri) {
|
||||||
|
cancelResolveUri(uri)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseOver() {
|
handleMouseOver() {
|
||||||
|
@ -47,6 +55,8 @@ class FileCard extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
claim,
|
||||||
|
fileInfo,
|
||||||
metadata,
|
metadata,
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
navigate,
|
navigate,
|
||||||
|
@ -61,6 +71,8 @@ class FileCard extends React.Component {
|
||||||
description = "Loading..."
|
description = "Loading..."
|
||||||
} else if (metadata && metadata.description) {
|
} else if (metadata && metadata.description) {
|
||||||
description = metadata.description
|
description = metadata.description
|
||||||
|
} else if (claim === null) {
|
||||||
|
description = 'This address contains no content.'
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -70,7 +82,10 @@ class FileCard extends React.Component {
|
||||||
<div className="card__title-identity">
|
<div className="card__title-identity">
|
||||||
<h5 title={title}><TruncatedText lines={1}>{title}</TruncatedText></h5>
|
<h5 title={title}><TruncatedText lines={1}>{title}</TruncatedText></h5>
|
||||||
<div className="card__subtitle">
|
<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} />
|
<UriIndicator uri={uri} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,6 +12,7 @@ import FilePrice from './view'
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
const selectCostInfoForUri = makeSelectCostInfoForUri()
|
const selectCostInfoForUri = makeSelectCostInfoForUri()
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
costInfo: selectCostInfoForUri(state, props),
|
costInfo: selectCostInfoForUri(state, props),
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
} from 'component/common'
|
} from 'component/common'
|
||||||
|
|
||||||
class FilePrice extends React.Component{
|
class FilePrice extends React.Component{
|
||||||
componentDidMount() {
|
componentWillMount() {
|
||||||
this.fetchCost(this.props)
|
this.fetchCost(this.props)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,8 @@ class FileTile extends React.Component {
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this._fileInfoSubscribeId = null
|
|
||||||
this._isMounted = null
|
|
||||||
this.state = {
|
this.state = {
|
||||||
showNsfwHelp: false,
|
showNsfwHelp: false,
|
||||||
isHidden: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,31 +26,11 @@ class FileTile extends React.Component {
|
||||||
uri,
|
uri,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
this._isMounted = true;
|
|
||||||
|
|
||||||
if (this.props.hideOnRemove) {
|
|
||||||
this._fileInfoSubscribeId = lbry.fileInfoSubscribe(this.props.outpoint, this.onFileInfoUpdate);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!isResolvingUri && !claim && uri) {
|
if(!isResolvingUri && !claim && uri) {
|
||||||
resolveUri(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() {
|
handleMouseOver() {
|
||||||
if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) {
|
if (this.props.obscureNsfw && this.props.metadata && this.props.metadata.nsfw) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -71,10 +48,6 @@ class FileTile extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
if (this.state.isHidden) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
claim,
|
claim,
|
||||||
metadata,
|
metadata,
|
||||||
|
|
|
@ -11,7 +11,7 @@ class VideoPlayButton extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onWatchClick() {
|
onWatchClick() {
|
||||||
console.log(this.props)
|
console.log(this)
|
||||||
this.props.purchaseUri(this.props.uri).then(() => {
|
this.props.purchaseUri(this.props.uri).then(() => {
|
||||||
if (!this.props.modal) {
|
if (!this.props.modal) {
|
||||||
this.props.startPlaying()
|
this.props.startPlaying()
|
||||||
|
@ -24,7 +24,6 @@ class VideoPlayButton extends React.Component {
|
||||||
button,
|
button,
|
||||||
label,
|
label,
|
||||||
className,
|
className,
|
||||||
onWatchClick,
|
|
||||||
metadata,
|
metadata,
|
||||||
metadata: {
|
metadata: {
|
||||||
title,
|
title,
|
||||||
|
@ -51,7 +50,7 @@ class VideoPlayButton extends React.Component {
|
||||||
label={label ? label : ""}
|
label={label ? label : ""}
|
||||||
className="video__play-button"
|
className="video__play-button"
|
||||||
icon="icon-play"
|
icon="icon-play"
|
||||||
onClick={this.onWatchClick} />
|
onClick={this.onWatchClick.bind(this)} />
|
||||||
{modal}
|
{modal}
|
||||||
<Modal contentLabel="Not enough credits" isOpen={modal == 'notEnoughCredits'} onConfirmed={closeModal}>
|
<Modal contentLabel="Not enough credits" isOpen={modal == 'notEnoughCredits'} onConfirmed={closeModal}>
|
||||||
You don't have enough LBRY credits to pay for this stream.
|
You don't have enough LBRY credits to pay for this stream.
|
||||||
|
@ -142,11 +141,9 @@ class VideoPlayer extends React.Component {
|
||||||
poster,
|
poster,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
//<source src={downloadPath} type={contentType} />
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<video controls id="video" ref="video" style={{backgroundImage: "url('" + poster + "')"}} >
|
<video controls id="video" ref="video" style={{backgroundImage: "url('" + poster + "')"}} >
|
||||||
|
<source src={downloadPath} type={contentType} />
|
||||||
</video>
|
</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 FETCH_FEATURED_CONTENT_COMPLETED = 'FETCH_FEATURED_CONTENT_COMPLETED'
|
||||||
export const RESOLVE_URI_STARTED = 'RESOLVE_URI_STARTED'
|
export const RESOLVE_URI_STARTED = 'RESOLVE_URI_STARTED'
|
||||||
export const RESOLVE_URI_COMPLETED = 'RESOLVE_URI_COMPLETED'
|
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_STARTED = 'FETCH_CHANNEL_CLAIMS_STARTED'
|
||||||
export const FETCH_CHANNEL_CLAIMS_COMPLETED = 'FETCH_CHANNEL_CLAIMS_COMPLETED'
|
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_STARTED = 'FETCH_DOWNLOADED_CONTENT_STARTED'
|
||||||
export const FETCH_DOWNLOADED_CONTENT_COMPLETED = 'FETCH_DOWNLOADED_CONTENT_COMPLETED'
|
export const FETCH_DOWNLOADED_CONTENT_COMPLETED = 'FETCH_DOWNLOADED_CONTENT_COMPLETED'
|
||||||
export const FETCH_PUBLISHED_CONTENT_STARTED = 'FETCH_PUBLISHED_CONTENT_STARTED'
|
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.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.checkAddressIsMine = function(address, callback) {
|
||||||
lbry.call('address_is_mine', {address: 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.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.getMyClaim = function(name, callback) {
|
||||||
lbry.call('claim_list_mine', {}, (claims) => {
|
lbry.call('claim_list_mine', {}, (claims) => {
|
||||||
callback(claims.find((claim) => claim.name == name) || null);
|
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
|
* Takes a LBRY URI; will first try and calculate a total cost using
|
||||||
* Lighthouse. If Lighthouse can't be reached, it just retrives the
|
* 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, {})
|
let costInfoCache = getSession(COST_INFO_CACHE_KEY, {})
|
||||||
|
|
||||||
function cacheAndResolve(cost, includesData) {
|
function cacheAndResolve(cost, includesData) {
|
||||||
console.log('getCostInfo cacheAndResolve ' + uri)
|
|
||||||
console.log(cost)
|
|
||||||
costInfoCache[uri] = {cost, includesData};
|
costInfoCache[uri] = {cost, includesData};
|
||||||
setSession(COST_INFO_CACHE_KEY, costInfoCache);
|
setSession(COST_INFO_CACHE_KEY, costInfoCache);
|
||||||
resolve({cost, includesData});
|
resolve({cost, includesData});
|
||||||
|
@ -509,10 +403,7 @@ lbry.stop = function(callback) {
|
||||||
lbry.call('stop', {}, callback);
|
lbry.call('stop', {}, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
lbry.fileInfo = {};
|
|
||||||
lbry._subscribeIdCount = 0;
|
lbry._subscribeIdCount = 0;
|
||||||
lbry._fileInfoSubscribeCallbacks = {};
|
|
||||||
lbry._fileInfoSubscribeInterval = 500000;
|
|
||||||
lbry._balanceSubscribeCallbacks = {};
|
lbry._balanceSubscribeCallbacks = {};
|
||||||
lbry._balanceSubscribeInterval = 5000;
|
lbry._balanceSubscribeInterval = 5000;
|
||||||
lbry._removedFiles = [];
|
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._balanceUpdateInterval = null;
|
||||||
lbry._updateBalanceSubscribers = function() {
|
lbry._updateBalanceSubscribers = function() {
|
||||||
lbry.get_balance().then(function(balance) {
|
lbry.get_balance().then(function(balance) {
|
||||||
|
|
|
@ -17,6 +17,9 @@ import {
|
||||||
import {
|
import {
|
||||||
doFetchDaemonSettings
|
doFetchDaemonSettings
|
||||||
} from 'actions/settings'
|
} from 'actions/settings'
|
||||||
|
import {
|
||||||
|
doFileList
|
||||||
|
} from 'actions/file_info'
|
||||||
import parseQueryParams from 'util/query_params'
|
import parseQueryParams from 'util/query_params'
|
||||||
|
|
||||||
const {remote, ipcRenderer} = require('electron');
|
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
|
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(doHistoryPush({}, "Discover", "/discover"))
|
||||||
app.store.dispatch(doFetchDaemonSettings())
|
app.store.dispatch(doFetchDaemonSettings())
|
||||||
|
app.store.dispatch(doFileList())
|
||||||
ReactDOM.render(<Provider store={store}><div>{ lbryio.enabled ? <AuthOverlay/> : '' }<App /><SnackBar /></div></Provider>, canvas)
|
ReactDOM.render(<Provider store={store}><div>{ lbryio.enabled ? <AuthOverlay/> : '' }<App /><SnackBar /></div></Provider>, canvas)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,10 @@ import {
|
||||||
} from 'react-redux'
|
} from 'react-redux'
|
||||||
import {
|
import {
|
||||||
doFetchDownloadedContent,
|
doFetchDownloadedContent,
|
||||||
} from 'actions/content'
|
} from 'actions/file_info'
|
||||||
import {
|
|
||||||
selectFetchingDownloadedContent,
|
|
||||||
} from 'selectors/content'
|
|
||||||
import {
|
import {
|
||||||
selectDownloadedFileInfo,
|
selectDownloadedFileInfo,
|
||||||
|
selectFetchingDownloadedContent,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
doNavigate,
|
doNavigate,
|
||||||
|
|
|
@ -100,7 +100,7 @@ var PublishPage = React.createClass({
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.state.isFee) {
|
if (this.state.isFee) {
|
||||||
lbry.getUnusedAddress((address) => {
|
lbry.wallet_unused_address().then((address) => {
|
||||||
metadata.fee = {};
|
metadata.fee = {};
|
||||||
metadata.fee[this.state.feeCurrency] = {
|
metadata.fee[this.state.feeCurrency] = {
|
||||||
amount: parseFloat(this.state.feeAmount),
|
amount: parseFloat(this.state.feeAmount),
|
||||||
|
|
|
@ -21,6 +21,8 @@ class ShowPage extends React.Component{
|
||||||
uri,
|
uri,
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
|
console.log('show page resolve ' + uri)
|
||||||
|
console.log('isResolving: ' + isResolvingUri)
|
||||||
if(!isResolvingUri && claim === undefined && uri) {
|
if(!isResolvingUri && claim === undefined && uri) {
|
||||||
resolveUri(uri)
|
resolveUri(uri)
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,9 +14,7 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
||||||
|
|
||||||
const newClaims = Object.assign({}, state.claimsByUri)
|
const newClaims = Object.assign({}, state.claimsByUri)
|
||||||
|
|
||||||
if (claim !== undefined) {
|
newClaims[uri] = claim
|
||||||
newClaims[uri] = claim
|
|
||||||
}
|
|
||||||
|
|
||||||
//This needs a sanity boost...
|
//This needs a sanity boost...
|
||||||
if (certificate !== undefined && claim === undefined) {
|
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) {
|
reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
|
|
|
@ -30,7 +30,7 @@ reducers[types.RESOLVE_URI_STARTED] = function(state, action) {
|
||||||
|
|
||||||
const oldResolving = state.resolvingUris || []
|
const oldResolving = state.resolvingUris || []
|
||||||
const newResolving = Object.assign([], oldResolving)
|
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, {
|
return Object.assign({}, state, {
|
||||||
resolvingUris: newResolving
|
resolvingUris: newResolving
|
||||||
|
@ -48,51 +48,14 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
||||||
...resolvingUris.slice(index + 1)
|
...resolvingUris.slice(index + 1)
|
||||||
]
|
]
|
||||||
|
|
||||||
const newState = Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
resolvingUris: newResolvingUris,
|
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) {
|
reducers[types.RESOLVE_URI_CANCELED] = function(state, action) {
|
||||||
const {
|
return reducers[types.RESOLVE_URI_COMPLETED](state, action)
|
||||||
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,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state = defaultState, action) {
|
||||||
|
|
|
@ -5,13 +5,35 @@ const reducers = {}
|
||||||
const defaultState = {
|
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) {
|
reducers[types.FETCH_FILE_INFO_STARTED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
outpoint
|
||||||
} = action.data
|
} = action.data
|
||||||
const newFetching = Object.assign({}, state.fetching)
|
const newFetching = Object.assign({}, state.fetching)
|
||||||
|
|
||||||
newFetching[uri] = true
|
newFetching[outpoint] = true
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
fetching: newFetching,
|
fetching: newFetching,
|
||||||
|
@ -20,19 +42,18 @@ reducers[types.FETCH_FILE_INFO_STARTED] = function(state, action) {
|
||||||
|
|
||||||
reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
outpoint,
|
||||||
} = action.data
|
} = action.data
|
||||||
|
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
const newFetching = Object.assign({}, state.fetching)
|
const newFetching = Object.assign({}, state.fetching)
|
||||||
|
|
||||||
newByUri[uri] = fileInfo || null
|
newFileInfos[outpoint] = fileInfo
|
||||||
|
delete newFetching[outpoint]
|
||||||
delete newFetching[uri]
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byUri: newByUri,
|
fileInfos: newFileInfos,
|
||||||
fetching: newFetching,
|
fetching: newFetching,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -40,9 +61,10 @@ reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
||||||
reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
const newDownloading = Object.assign({}, state.downloading)
|
const newDownloading = Object.assign({}, state.downloading)
|
||||||
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
||||||
const newLoading = Object.assign({}, state.loading)
|
const newLoading = Object.assign({}, state.loading)
|
||||||
|
@ -50,13 +72,13 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
||||||
|
|
||||||
newDownloadingByUri[uri] = true
|
newDownloadingByUri[uri] = true
|
||||||
newDownloading.byUri = newDownloadingByUri
|
newDownloading.byUri = newDownloadingByUri
|
||||||
newByUri[uri] = fileInfo
|
newFileInfos[outpoint] = fileInfo
|
||||||
delete newLoadingByUri[uri]
|
delete newLoadingByUri[uri]
|
||||||
newLoading.byUri = newLoadingByUri
|
newLoading.byUri = newLoadingByUri
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
downloading: newDownloading,
|
downloading: newDownloading,
|
||||||
byUri: newByUri,
|
fileInfos: newFileInfos,
|
||||||
loading: newLoading,
|
loading: newLoading,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -64,16 +86,17 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
|
||||||
reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
|
reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
const newDownloading = Object.assign({}, state.downloading)
|
const newDownloading = Object.assign({}, state.downloading)
|
||||||
|
|
||||||
newByUri[uri] = fileInfo
|
newFileInfos[outpoint] = fileInfo
|
||||||
newDownloading[uri] = true
|
newDownloading[uri] = true
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byUri: newByUri,
|
fileInfos: newByUri,
|
||||||
downloading: newDownloading
|
downloading: newDownloading
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -81,31 +104,32 @@ reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
|
||||||
reducers[types.DOWNLOADING_COMPLETED] = function(state, action) {
|
reducers[types.DOWNLOADING_COMPLETED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
uri,
|
||||||
|
outpoint,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
const newDownloading = Object.assign({}, state.downloading)
|
const newDownloading = Object.assign({}, state.downloading)
|
||||||
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
|
||||||
|
|
||||||
newByUri[uri] = fileInfo
|
newFileInfos[outpoint] = fileInfo
|
||||||
delete newDownloadingByUri[uri]
|
delete newDownloadingByUri[uri]
|
||||||
newDownloading.byUri = newDownloadingByUri
|
newDownloading.byUri = newDownloadingByUri
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byUri: newByUri,
|
fileInfos: newFileInfos,
|
||||||
downloading: newDownloading,
|
downloading: newDownloading,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
reducers[types.DELETE_FILE_STARTED] = function(state, action) {
|
reducers[types.DELETE_FILE_STARTED] = function(state, action) {
|
||||||
const {
|
const {
|
||||||
uri,
|
outpoint
|
||||||
} = action.data
|
} = action.data
|
||||||
const newDeleting = Object.assign({}, state.deleting)
|
const newDeleting = Object.assign({}, state.deleting)
|
||||||
const newByUri = Object.assign({}, newDeleting.byUri)
|
const newByUri = Object.assign({}, newDeleting.byUri)
|
||||||
|
|
||||||
newByUri[uri] = true
|
newFileInfos[outpoint] = true
|
||||||
newDeleting.byUri = newByUri
|
newDeleting.byUri = newFileInfos
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
deleting: newDeleting,
|
deleting: newDeleting,
|
||||||
|
@ -118,15 +142,15 @@ reducers[types.DELETE_FILE_COMPLETED] = function(state, action) {
|
||||||
} = action.data
|
} = action.data
|
||||||
const newDeleting = Object.assign({}, state.deleting)
|
const newDeleting = Object.assign({}, state.deleting)
|
||||||
const newDeletingByUri = Object.assign({}, newDeleting.byUri)
|
const newDeletingByUri = Object.assign({}, newDeleting.byUri)
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
|
|
||||||
delete newDeletingByUri[uri]
|
delete newDeletingByUri[uri]
|
||||||
newDeleting.byUri = newDeletingByUri
|
newDeleting.byUri = newDeletingByUri
|
||||||
delete newByUri[uri]
|
delete newFileInfos[outpoint]
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
deleting: newDeleting,
|
deleting: newDeleting,
|
||||||
byUri: newByUri,
|
fileInfos: newFileInfos,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,10 +159,10 @@ reducers[types.LOADING_VIDEO_STARTED] = function(state, action) {
|
||||||
uri,
|
uri,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newLoading = Object.assign({}, state.loading)
|
const newLoading = Object.assign({}, state.loading)
|
||||||
const newByUri = Object.assign({}, newLoading.byUri)
|
const newFileInfos = Object.assign({}, newLoading.byUri)
|
||||||
|
|
||||||
newByUri[uri] = true
|
newFileInfos[outpoint] = true
|
||||||
newLoading.byUri = newByUri
|
newLoading.byUri = newFileInfos
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
loading: newLoading,
|
loading: newLoading,
|
||||||
|
@ -150,33 +174,38 @@ reducers[types.LOADING_VIDEO_FAILED] = function(state, action) {
|
||||||
uri,
|
uri,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newLoading = Object.assign({}, state.loading)
|
const newLoading = Object.assign({}, state.loading)
|
||||||
const newByUri = Object.assign({}, newLoading.byUri)
|
const newFileInfos = Object.assign({}, newLoading.byUri)
|
||||||
|
|
||||||
delete newByUri[uri]
|
delete newFileInfos[outpoint]
|
||||||
newLoading.byUri = newByUri
|
newLoading.byUri = newFileInfos
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
loading: newLoading,
|
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) {
|
reducers[types.FETCH_DOWNLOADED_CONTENT_COMPLETED] = function(state, action) {
|
||||||
const {
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
fileInfos,
|
|
||||||
} = action.data
|
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
|
||||||
|
|
||||||
fileInfos.forEach(fileInfo => {
|
action.data.fileInfos.forEach(fileInfo => {
|
||||||
const uri = lbryuri.build({
|
newFileInfos[fileInfo.outpoint] = fileInfo
|
||||||
channelName: fileInfo.channel_name,
|
|
||||||
contentName: fileInfo.name,
|
|
||||||
})
|
|
||||||
|
|
||||||
newByUri[uri] = fileInfo
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
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 {
|
const {
|
||||||
fileInfos
|
fileInfos
|
||||||
} = action.data
|
} = action.data
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newFileInfos = Object.assign({}, state.fileInfos)
|
||||||
|
|
||||||
fileInfos.forEach(fileInfo => {
|
fileInfos.forEach(fileInfo => {
|
||||||
const uri = lbryuri.build({
|
newFileInfos[fileInfo.outpoint] = fileInfo
|
||||||
channelName: fileInfo.channel_name,
|
|
||||||
contentName: fileInfo.name,
|
|
||||||
})
|
|
||||||
|
|
||||||
newByUri[uri] = fileInfo
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
byUri: newByUri
|
fileInfos: newFileInfos,
|
||||||
|
fetchingPublishedContent: false
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export default function reducer(state = defaultState, action) {
|
export default function reducer(state = defaultState, action) {
|
||||||
const handler = reducers[action.type];
|
const handler = reducers[action.type];
|
||||||
if (handler) return handler(state, action);
|
if (handler) return handler(state, action);
|
||||||
|
|
|
@ -16,32 +16,6 @@ export const selectFetchingFeaturedUris = createSelector(
|
||||||
(state) => !!state.fetchingFeaturedContent
|
(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(
|
export const selectResolvingUris = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.resolvingUris || []
|
(state) => state.resolvingUris || []
|
||||||
|
|
|
@ -2,14 +2,20 @@ import {
|
||||||
createSelector,
|
createSelector,
|
||||||
} from 'reselect'
|
} from 'reselect'
|
||||||
import {
|
import {
|
||||||
|
selectClaimsByUri,
|
||||||
selectMyClaimsOutpoints,
|
selectMyClaimsOutpoints,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
|
|
||||||
export const _selectState = state => state.fileInfo || {}
|
export const _selectState = state => state.fileInfo || {}
|
||||||
|
|
||||||
export const selectAllFileInfoByUri = createSelector(
|
export const selectIsFileListPending = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.byUri || {}
|
(state) => state.isFileListPending
|
||||||
|
)
|
||||||
|
|
||||||
|
export const selectAllFileInfos = createSelector(
|
||||||
|
_selectState,
|
||||||
|
(state) => state.fileInfos || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectDownloading = createSelector(
|
export const selectDownloading = createSelector(
|
||||||
|
@ -22,8 +28,42 @@ export const selectDownloadingByUri = createSelector(
|
||||||
(downloading) => downloading.byUri || {}
|
(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) => {
|
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 = () => {
|
export const makeSelectFileInfoForUri = () => {
|
||||||
|
@ -68,23 +108,21 @@ export const makeSelectLoadingForUri = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
export const selectDownloadedFileInfo = createSelector(
|
export const selectDownloadedFileInfo = createSelector(
|
||||||
selectAllFileInfoByUri,
|
selectAllFileInfos,
|
||||||
(byUri) => {
|
(fileInfos) => {
|
||||||
const fileInfoList = []
|
const fileInfoList = []
|
||||||
Object.keys(byUri).forEach(key => {
|
Object.keys(fileInfos).forEach(outpoint => {
|
||||||
const fileInfo = byUri[key]
|
const fileInfo = fileInfos[outpoint]
|
||||||
|
|
||||||
if (fileInfo.completed || fileInfo.written_bytes) {
|
if (fileInfo.completed || fileInfo.written_bytes) {
|
||||||
fileInfoList.push(fileInfo)
|
fileInfoList.push(fileInfo)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
return fileInfoList
|
return fileInfoList
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectPublishedFileInfo = createSelector(
|
export const selectPublishedFileInfo = createSelector(
|
||||||
selectAllFileInfoByUri,
|
selectAllFileInfos,
|
||||||
selectMyClaimsOutpoints,
|
selectMyClaimsOutpoints,
|
||||||
(byUri, outpoints) => {
|
(byUri, outpoints) => {
|
||||||
const fileInfos = []
|
const fileInfos = []
|
||||||
|
|
Loading…
Add table
Reference in a new issue