i'm making things better... right?
This commit is contained in:
parent
0fad6864ec
commit
6783bcdfeb
35 changed files with 346 additions and 556 deletions
|
@ -6,7 +6,6 @@ import {
|
||||||
selectUpgradeDownloadItem,
|
selectUpgradeDownloadItem,
|
||||||
selectUpgradeFilename,
|
selectUpgradeFilename,
|
||||||
selectPageTitle,
|
selectPageTitle,
|
||||||
selectCurrentPath,
|
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
|
|
||||||
const {remote, ipcRenderer, shell} = require('electron');
|
const {remote, ipcRenderer, shell} = require('electron');
|
||||||
|
|
|
@ -1,39 +1,29 @@
|
||||||
import * as types from 'constants/action_types'
|
import * as types from 'constants/action_types'
|
||||||
import lbry from 'lbry'
|
import lbry from 'lbry'
|
||||||
import {
|
import {
|
||||||
selectCurrentUri,
|
selectFetchingAvailability
|
||||||
} from 'selectors/app'
|
} from 'selectors/availability'
|
||||||
|
|
||||||
export function doFetchUriAvailability(uri) {
|
export function doFetchAvailability(uri) {
|
||||||
return function(dispatch, getState) {
|
|
||||||
dispatch({
|
|
||||||
type: types.FETCH_AVAILABILITY_STARTED,
|
|
||||||
data: { uri }
|
|
||||||
})
|
|
||||||
|
|
||||||
const successCallback = (availability) => {
|
|
||||||
dispatch({
|
|
||||||
type: types.FETCH_AVAILABILITY_COMPLETED,
|
|
||||||
data: {
|
|
||||||
availability,
|
|
||||||
uri,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorCallback = () => {
|
|
||||||
console.debug('error')
|
|
||||||
}
|
|
||||||
|
|
||||||
lbry.get_availability({ uri }, successCallback, errorCallback)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function doFetchCurrentUriAvailability() {
|
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const uri = selectCurrentUri(state)
|
const alreadyFetching = !!selectFetchingAvailability(state)[uri]
|
||||||
|
|
||||||
dispatch(doFetchUriAvailability(uri))
|
if (!alreadyFetching) {
|
||||||
|
dispatch({
|
||||||
|
type: types.FETCH_AVAILABILITY_STARTED,
|
||||||
|
data: {uri}
|
||||||
|
})
|
||||||
|
|
||||||
|
lbry.get_availability({uri}).then((availability) => {
|
||||||
|
dispatch({
|
||||||
|
type: types.FETCH_AVAILABILITY_COMPLETED,
|
||||||
|
data: {
|
||||||
|
availability,
|
||||||
|
uri,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -3,18 +3,15 @@ import lbry from 'lbry'
|
||||||
import lbryio from 'lbryio'
|
import lbryio from 'lbryio'
|
||||||
import lbryuri from 'lbryuri'
|
import lbryuri from 'lbryuri'
|
||||||
import rewards from 'rewards'
|
import rewards from 'rewards'
|
||||||
import {
|
|
||||||
selectCurrentUri,
|
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
import {
|
||||||
selectBalance,
|
selectBalance,
|
||||||
} from 'selectors/wallet'
|
} from 'selectors/wallet'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriFileInfo,
|
selectFileInfoForUri,
|
||||||
selectDownloadingByUri,
|
selectDownloadingByUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriCostInfo,
|
selectCostInfoForUri,
|
||||||
} from 'selectors/cost_info'
|
} from 'selectors/cost_info'
|
||||||
import {
|
import {
|
||||||
selectClaimsByUri,
|
selectClaimsByUri,
|
||||||
|
@ -44,15 +41,6 @@ export function doResolveUri(uri) {
|
||||||
certificate,
|
certificate,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
|
||||||
dispatch({
|
|
||||||
type: types.RESOLVE_URI_COMPLETED,
|
|
||||||
data: {
|
|
||||||
uri,
|
|
||||||
claim: null,
|
|
||||||
certificate: null,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -120,8 +108,6 @@ export function doFetchPublishedContent() {
|
||||||
|
|
||||||
export function doFetchFeaturedUris() {
|
export function doFetchFeaturedUris() {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
return
|
|
||||||
|
|
||||||
const state = getState()
|
const state = getState()
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
|
@ -229,10 +215,9 @@ export function doDownloadFile(uri, streamInfo) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doLoadVideo() {
|
export function doLoadVideo(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const uri = selectCurrentUri(state)
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.LOADING_VIDEO_STARTED,
|
type: types.LOADING_VIDEO_STARTED,
|
||||||
|
@ -259,13 +244,12 @@ export function doLoadVideo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doWatchVideo() {
|
export function doWatchVideo(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const uri = selectCurrentUri(state)
|
|
||||||
const balance = selectBalance(state)
|
const balance = selectBalance(state)
|
||||||
const fileInfo = selectCurrentUriFileInfo(state)
|
const fileInfo = selectFileInfoForUri(state, { uri })
|
||||||
const costInfo = selectCurrentUriCostInfo(state)
|
const costInfo = selectCostInfoForUri(state, { uri })
|
||||||
const downloadingByUri = selectDownloadingByUri(state)
|
const downloadingByUri = selectDownloadingByUri(state)
|
||||||
const alreadyDownloading = !!downloadingByUri[uri]
|
const alreadyDownloading = !!downloadingByUri[uri]
|
||||||
const { cost } = costInfo
|
const { cost } = costInfo
|
||||||
|
@ -287,8 +271,8 @@ export function doWatchVideo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// the file is free or we have partially downloaded it
|
// the file is free or we have partially downloaded it
|
||||||
if (cost <= 0.01 || fileInfo.download_directory) {
|
if (cost <= 0.01 || (fileInfo && fileInfo.download_directory)) {
|
||||||
dispatch(doLoadVideo())
|
dispatch(doLoadVideo(uri))
|
||||||
return Promise.resolve()
|
return Promise.resolve()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,7 +286,7 @@ export function doWatchVideo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function doFetchChannelClaims(uri) {
|
export function doFetchClaimsByChannel(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_CHANNEL_CLAIMS_STARTED,
|
type: types.FETCH_CHANNEL_CLAIMS_STARTED,
|
||||||
|
@ -323,7 +307,7 @@ export function doFetchChannelClaims(uri) {
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_CHANNEL_CLAIMS_COMPLETED,
|
type: types.FETC,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
claims: []
|
claims: []
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
import * as types from 'constants/action_types'
|
import * as types from 'constants/action_types'
|
||||||
import {
|
|
||||||
selectCurrentUri,
|
|
||||||
} from 'selectors/app'
|
|
||||||
import lbry from 'lbry'
|
import lbry from 'lbry'
|
||||||
|
|
||||||
export function doFetchCostInfoForUri(uri) {
|
export function doFetchCostInfoForUri(uri) {
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import * as types from 'constants/action_types'
|
import * as types from 'constants/action_types'
|
||||||
import lbry from 'lbry'
|
import lbry from 'lbry'
|
||||||
import {
|
import {
|
||||||
selectCurrentUri,
|
selectClaimsByUri,
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
|
||||||
selectCurrentUriClaimOutpoint,
|
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
|
import {
|
||||||
|
selectLoadingByUri,
|
||||||
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
doCloseModal,
|
doCloseModal,
|
||||||
} from 'actions/app'
|
} from 'actions/app'
|
||||||
|
@ -14,29 +14,39 @@ const {
|
||||||
shell,
|
shell,
|
||||||
} = require('electron')
|
} = require('electron')
|
||||||
|
|
||||||
export function doFetchCurrentUriFileInfo() {
|
export function doFetchFileInfo(uri) {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
const uri = selectCurrentUri(state)
|
const claim = selectClaimsByUri(state)[uri]
|
||||||
const outpoint = selectCurrentUriClaimOutpoint(state)
|
const outpoint = claim ? `${claim.txid}:${claim.nout}` : null
|
||||||
|
const alreadyFetching = !!selectLoadingByUri(state)[uri]
|
||||||
|
|
||||||
dispatch({
|
if (!outpoint) {
|
||||||
type: types.FETCH_FILE_INFO_STARTED,
|
console.log(claim);
|
||||||
data: {
|
console.log(outpoint);
|
||||||
uri,
|
console.log(selectClaimsByUri(state))
|
||||||
outpoint,
|
throw new Error("Unable to get outpoint from claim for URI " + uri);
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
|
||||||
lbry.file_list({ outpoint: outpoint, full_status: true }).then(([fileInfo]) => {
|
if (!alreadyFetching) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: types.FETCH_FILE_INFO_COMPLETED,
|
type: types.FETCH_FILE_INFO_STARTED,
|
||||||
data: {
|
data: {
|
||||||
uri,
|
uri,
|
||||||
fileInfo,
|
outpoint,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
lbry.file_list({outpoint: outpoint, full_status: true}).then(([fileInfo]) => {
|
||||||
|
dispatch({
|
||||||
|
type: types.FETCH_FILE_INFO_COMPLETED,
|
||||||
|
data: {
|
||||||
|
uri,
|
||||||
|
fileInfo,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,30 +2,19 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux'
|
import { connect } from 'react-redux'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
selectCurrentPage,
|
|
||||||
selectCurrentModal,
|
selectCurrentModal,
|
||||||
selectDrawerOpen,
|
|
||||||
selectHeaderLinks,
|
|
||||||
selectSearchTerm,
|
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
import {
|
import {
|
||||||
doCheckUpgradeAvailable,
|
doCheckUpgradeAvailable,
|
||||||
doOpenModal,
|
|
||||||
doCloseModal,
|
|
||||||
} from 'actions/app'
|
} from 'actions/app'
|
||||||
import App from './view'
|
import App from './view'
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
currentPage: selectCurrentPage(state),
|
|
||||||
modal: selectCurrentModal(state),
|
modal: selectCurrentModal(state),
|
||||||
headerLinks: selectHeaderLinks(state),
|
|
||||||
searchTerm: selectSearchTerm(state)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
|
checkUpgradeAvailable: () => dispatch(doCheckUpgradeAvailable()),
|
||||||
openModal: () => dispatch(doOpenModal()),
|
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(select, perform)(App)
|
export default connect(select, perform)(App)
|
||||||
|
|
|
@ -20,7 +20,6 @@ class App extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
modal,
|
modal,
|
||||||
headerLinks,
|
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
return <div id="window">
|
return <div id="window">
|
||||||
|
|
|
@ -3,8 +3,6 @@ import {
|
||||||
connect,
|
connect,
|
||||||
} from 'react-redux'
|
} from 'react-redux'
|
||||||
import {
|
import {
|
||||||
selectObscureNsfw,
|
|
||||||
selectHidePrice,
|
|
||||||
selectHasSignature,
|
selectHasSignature,
|
||||||
selectPlatform,
|
selectPlatform,
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
|
@ -14,7 +12,7 @@ import {
|
||||||
makeSelectLoadingForUri,
|
makeSelectLoadingForUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
makeSelectAvailabilityForUri,
|
makeSelectIsAvailableForUri,
|
||||||
} from 'selectors/availability'
|
} from 'selectors/availability'
|
||||||
import {
|
import {
|
||||||
selectCurrentModal,
|
selectCurrentModal,
|
||||||
|
@ -23,6 +21,9 @@ import {
|
||||||
doCloseModal,
|
doCloseModal,
|
||||||
doOpenModal,
|
doOpenModal,
|
||||||
} from 'actions/app'
|
} from 'actions/app'
|
||||||
|
import {
|
||||||
|
doFetchAvailability
|
||||||
|
} from 'actions/availability'
|
||||||
import {
|
import {
|
||||||
doOpenFileInShell,
|
doOpenFileInShell,
|
||||||
doOpenFileInFolder,
|
doOpenFileInFolder,
|
||||||
|
@ -36,33 +37,29 @@ import FileActions from './view'
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
||||||
const selectAvailabilityForUri = makeSelectAvailabilityForUri()
|
const selectIsAvailableForUri = makeSelectIsAvailableForUri()
|
||||||
const selectDownloadingForUri = makeSelectDownloadingForUri()
|
const selectDownloadingForUri = makeSelectDownloadingForUri()
|
||||||
const selectLoadingForUri = makeSelectLoadingForUri()
|
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
obscureNsfw: selectObscureNsfw(state),
|
|
||||||
hidePrice: selectHidePrice(state),
|
|
||||||
hasSignature: selectHasSignature(state),
|
|
||||||
fileInfo: selectFileInfoForUri(state, props),
|
fileInfo: selectFileInfoForUri(state, props),
|
||||||
availability: selectAvailabilityForUri(state, props),
|
isAvailable: selectIsAvailableForUri(state, props),
|
||||||
platform: selectPlatform(state),
|
platform: selectPlatform(state),
|
||||||
modal: selectCurrentModal(state),
|
modal: selectCurrentModal(state),
|
||||||
downloading: selectDownloadingForUri(state, props),
|
downloading: selectDownloadingForUri(state, props),
|
||||||
loading: selectLoadingForUri(state, props),
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return select
|
return select
|
||||||
}
|
}
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
|
checkAvailability: (uri) => dispatch(doFetchAvailability(uri)),
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
openInFolder: (fileInfo) => dispatch(doOpenFileInFolder(fileInfo)),
|
||||||
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
openInShell: (fileInfo) => dispatch(doOpenFileInShell(fileInfo)),
|
||||||
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
deleteFile: (fileInfo, deleteFromComputer) => dispatch(doDeleteFile(fileInfo, deleteFromComputer)),
|
||||||
openModal: (modal) => dispatch(doOpenModal(modal)),
|
openModal: (modal) => dispatch(doOpenModal(modal)),
|
||||||
downloadClick: () => dispatch(doWatchVideo()),
|
startDownload: (uri) => dispatch(doWatchVideo(uri)),
|
||||||
loadVideo: () => dispatch(doLoadVideo())
|
loadVideo: (uri) => dispatch(doLoadVideo(uri))
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(makeSelect, perform)(FileActions)
|
export default connect(makeSelect, perform)(FileActions)
|
|
@ -1,7 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import lbry from 'lbry';
|
import {Icon,BusyMessage} from 'component/common';
|
||||||
import lbryuri from 'lbryuri';
|
|
||||||
import {Icon,} from 'component/common';
|
|
||||||
import FilePrice from 'component/filePrice'
|
import FilePrice from 'component/filePrice'
|
||||||
import {Modal} from 'component/modal';
|
import {Modal} from 'component/modal';
|
||||||
import {FormField} from 'component/form';
|
import {FormField} from 'component/form';
|
||||||
|
@ -9,14 +7,36 @@ import Link from 'component/link';
|
||||||
import {ToolTip} from 'component/tooltip';
|
import {ToolTip} from 'component/tooltip';
|
||||||
import {DropDownMenu, DropDownMenuItem} from 'component/menu';
|
import {DropDownMenu, DropDownMenuItem} from 'component/menu';
|
||||||
|
|
||||||
class FileActionsRow extends React.Component {
|
class FileActions extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
this.state = {
|
this.state = {
|
||||||
|
forceShowActions: false,
|
||||||
deleteChecked: false,
|
deleteChecked: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillMount() {
|
||||||
|
this.checkAvailability(this.props.uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
this.checkAvailability(nextProps.uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
checkAvailability(uri) {
|
||||||
|
if (!this._uri || uri !== this._uri) {
|
||||||
|
this._uri = uri;
|
||||||
|
this.props.checkAvailability(uri)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onShowFileActionsRowClicked() {
|
||||||
|
this.setState({
|
||||||
|
forceShowActions: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleDeleteCheckboxClicked(event) {
|
handleDeleteCheckboxClicked(event) {
|
||||||
this.setState({
|
this.setState({
|
||||||
deleteChecked: event.target.checked,
|
deleteChecked: event.target.checked,
|
||||||
|
@ -25,65 +45,73 @@ class FileActionsRow extends React.Component {
|
||||||
|
|
||||||
onAffirmPurchase() {
|
onAffirmPurchase() {
|
||||||
this.props.closeModal()
|
this.props.closeModal()
|
||||||
this.props.loadVideo()
|
this.props.loadVideo(this.props.uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
fileInfo,
|
fileInfo,
|
||||||
|
isAvailable,
|
||||||
platform,
|
platform,
|
||||||
downloading,
|
downloading,
|
||||||
loading,
|
|
||||||
uri,
|
uri,
|
||||||
deleteFile,
|
deleteFile,
|
||||||
openInFolder,
|
openInFolder,
|
||||||
openInShell,
|
openInShell,
|
||||||
modal,
|
modal,
|
||||||
openModal,
|
openModal,
|
||||||
affirmPurchase,
|
|
||||||
closeModal,
|
closeModal,
|
||||||
downloadClick,
|
startDownload,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const {
|
const deleteChecked = this.state.deleteChecked,
|
||||||
deleteChecked,
|
metadata = fileInfo ? fileInfo.metadata : null,
|
||||||
} = this.state
|
openInFolderMessage = platform.startsWith('Mac') ? 'Open in Finder' : 'Open in Folder',
|
||||||
|
showMenu = fileInfo && Object.keys(fileInfo).length > 0,
|
||||||
|
title = metadata ? metadata.title : uri;
|
||||||
|
|
||||||
const metadata = fileInfo ? fileInfo.metadata : null
|
let content
|
||||||
|
|
||||||
if (!fileInfo)
|
if (fileInfo === undefined || isAvailable === undefined) {
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const openInFolderMessage = platform.startsWith('Mac') ? 'Open in Finder' : 'Open in Folder',
|
content = <BusyMessage message="Checking availability" />
|
||||||
showMenu = Object.keys(fileInfo).length != 0;
|
|
||||||
|
} else if (!isAvailable && !this.state.forceShowActions) {
|
||||||
|
|
||||||
|
content = <div>
|
||||||
|
<div className="button-set-item empty">Content unavailable.</div>
|
||||||
|
<ToolTip label="Why?"
|
||||||
|
body="The content on LBRY is hosted by its users. It appears there are no users connected that have this file at the moment."
|
||||||
|
className="button-set-item" />
|
||||||
|
<Link label="Try Anyway" onClick={this.onShowFileActionsRowClicked.bind(this)} className="button-text button-set-item" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
} else if (fileInfo === null && !downloading) {
|
||||||
|
|
||||||
|
content = <Link button="text" label="Download" icon="icon-download" onClick={() => { startDownload(uri) } } />;
|
||||||
|
|
||||||
|
} else if (downloading) {
|
||||||
|
|
||||||
let linkBlock;
|
|
||||||
if (Object.keys(fileInfo).length == 0 && !downloading && !loading) {
|
|
||||||
linkBlock = <Link button="text" label="Download" icon="icon-download" onClick={downloadClick} />;
|
|
||||||
} else if (downloading || loading) {
|
|
||||||
const
|
const
|
||||||
progress = (fileInfo && fileInfo.written_bytes) ? fileInfo.written_bytes / fileInfo.total_bytes * 100 : 0,
|
progress = (fileInfo && fileInfo.written_bytes) ? fileInfo.written_bytes / fileInfo.total_bytes * 100 : 0,
|
||||||
label = fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...',
|
label = fileInfo ? progress.toFixed(0) + '% complete' : 'Connecting...',
|
||||||
labelWithIcon = <span className="button__content"><Icon icon="icon-download" /><span>{label}</span></span>;
|
labelWithIcon = <span className="button__content"><Icon icon="icon-download" /><span>{label}</span></span>;
|
||||||
|
|
||||||
linkBlock = (
|
content = <div className="faux-button-block file-actions__download-status-bar button-set-item">
|
||||||
<div className="faux-button-block file-actions__download-status-bar button-set-item">
|
<div className="faux-button-block file-actions__download-status-bar-overlay" style={{ width: progress + '%' }}>{labelWithIcon}</div>
|
||||||
<div className="faux-button-block file-actions__download-status-bar-overlay" style={{ width: progress + '%' }}>{labelWithIcon}</div>
|
{labelWithIcon}
|
||||||
{labelWithIcon}
|
</div>
|
||||||
</div>
|
|
||||||
);
|
} else if (fileInfo && fileInfo.download_path) {
|
||||||
|
content = <Link label="Open" button="text" icon="icon-folder-open" onClick={() => openInShell(fileInfo)} />;
|
||||||
} else {
|
} else {
|
||||||
linkBlock = <Link label="Open" button="text" icon="icon-folder-open" onClick={() => openInShell(fileInfo)} />;
|
console.log('handle this case of file action props?');
|
||||||
|
console.log(this.props)
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = metadata ? metadata.title : uri;
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<section className="file-actions">
|
||||||
{fileInfo !== null || fileInfo.isMine
|
{ content }
|
||||||
? linkBlock
|
|
||||||
: null}
|
|
||||||
{ showMenu ?
|
{ showMenu ?
|
||||||
<DropDownMenu>
|
<DropDownMenu>
|
||||||
<DropDownMenuItem key={0} onClick={() => openInFolder(fileInfo)} label={openInFolderMessage} />
|
<DropDownMenuItem key={0} onClick={() => openInFolder(fileInfo)} label={openInFolderMessage} />
|
||||||
|
@ -102,62 +130,18 @@ class FileActionsRow extends React.Component {
|
||||||
LBRY was unable to download the stream <strong>{uri}</strong>.
|
LBRY was unable to download the stream <strong>{uri}</strong>.
|
||||||
</Modal>
|
</Modal>
|
||||||
<Modal isOpen={modal == 'confirmRemove'}
|
<Modal isOpen={modal == 'confirmRemove'}
|
||||||
contentLabel="Not enough credits"
|
contentLabel="Not enough credits"
|
||||||
type="confirm"
|
type="confirm"
|
||||||
confirmButtonLabel="Remove"
|
confirmButtonLabel="Remove"
|
||||||
onConfirmed={() => deleteFile(uri, fileInfo, deleteChecked)}
|
onConfirmed={() => deleteFile(uri, fileInfo, deleteChecked)}
|
||||||
onAborted={closeModal}>
|
onAborted={closeModal}>
|
||||||
<p>Are you sure you'd like to remove <cite>{title}</cite> from LBRY?</p>
|
<p>Are you sure you'd like to remove <cite>{title}</cite> from LBRY?</p>
|
||||||
|
|
||||||
<label><FormField type="checkbox" checked={deleteChecked} onClick={this.handleDeleteCheckboxClicked.bind(this)} /> Delete this file from my computer</label>
|
<label><FormField type="checkbox" checked={deleteChecked} onClick={this.handleDeleteCheckboxClicked.bind(this)} /> Delete this file from my computer</label>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</section>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class FileActions extends React.Component {
|
|
||||||
constructor(props) {
|
|
||||||
super(props)
|
|
||||||
this._isMounted = false
|
|
||||||
this._fileInfoSubscribeId = null
|
|
||||||
this.state = {
|
|
||||||
available: true,
|
|
||||||
forceShowActions: false,
|
|
||||||
fileInfo: null,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onShowFileActionsRowClicked() {
|
|
||||||
this.setState({
|
|
||||||
forceShowActions: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
fileInfo,
|
|
||||||
availability,
|
|
||||||
} = this.props
|
|
||||||
|
|
||||||
if (fileInfo === null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (<section className="file-actions">
|
|
||||||
{
|
|
||||||
fileInfo || this.state.available || this.state.forceShowActions
|
|
||||||
? <FileActionsRow {...this.props} />
|
|
||||||
: <div>
|
|
||||||
<div className="button-set-item empty">Content unavailable.</div>
|
|
||||||
<ToolTip label="Why?"
|
|
||||||
body="The content on LBRY is hosted by its users. It appears there are no users connected that have this file at the moment."
|
|
||||||
className="button-set-item" />
|
|
||||||
<Link label="Try Anyway" onClick={this.onShowFileActionsRowClicked.bind(this)} className="button-text button-set-item" />
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</section>);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default FileActions
|
export default FileActions
|
||||||
|
|
|
@ -9,19 +9,17 @@ import {
|
||||||
doResolveUri,
|
doResolveUri,
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import {
|
import {
|
||||||
selectHidePrice,
|
|
||||||
selectObscureNsfw,
|
selectObscureNsfw,
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectSourceForUri,
|
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import {
|
import {
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
makeSelectResolvingUri,
|
makeSelectIsResolvingForUri,
|
||||||
} from 'selectors/content'
|
} from 'selectors/content'
|
||||||
import FileCard from './view'
|
import FileCard from './view'
|
||||||
|
|
||||||
|
@ -29,17 +27,14 @@ const makeSelect = () => {
|
||||||
const selectClaimForUri = makeSelectClaimForUri()
|
const selectClaimForUri = makeSelectClaimForUri()
|
||||||
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
||||||
const selectMetadataForUri = makeSelectMetadataForUri()
|
const selectMetadataForUri = makeSelectMetadataForUri()
|
||||||
const selectSourceForUri = makeSelectSourceForUri()
|
const selectResolvingUri = makeSelectIsResolvingForUri()
|
||||||
const selectResolvingUri = makeSelectResolvingUri()
|
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: selectClaimForUri(state, props),
|
claim: selectClaimForUri(state, props),
|
||||||
fileInfo: selectFileInfoForUri(state, props),
|
fileInfo: selectFileInfoForUri(state, props),
|
||||||
hidePrice: selectHidePrice(state),
|
|
||||||
obscureNsfw: selectObscureNsfw(state),
|
obscureNsfw: selectObscureNsfw(state),
|
||||||
hasSignature: false,
|
hasSignature: false,
|
||||||
metadata: selectMetadataForUri(state, props),
|
metadata: selectMetadataForUri(state, props),
|
||||||
source: selectSourceForUri(state, props),
|
|
||||||
isResolvingUri: selectResolvingUri(state, props),
|
isResolvingUri: selectResolvingUri(state, props),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@ class FileCard extends React.Component {
|
||||||
metadata,
|
metadata,
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
navigate,
|
navigate,
|
||||||
hidePrice,
|
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const uri = lbryuri.normalize(this.props.uri);
|
const uri = lbryuri.normalize(this.props.uri);
|
||||||
|
@ -59,7 +58,7 @@ 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">
|
||||||
{ !hidePrice ? <span style={{float: "right"}}><FilePrice uri={uri} /></span> : null}
|
<span style={{float: "right"}}><FilePrice uri={uri} /></span>
|
||||||
<UriIndicator uri={uri} />
|
<UriIndicator uri={uri} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -10,41 +10,30 @@ import {
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import {
|
import {
|
||||||
makeSelectClaimForUri,
|
makeSelectClaimForUri,
|
||||||
makeSelectSourceForUri,
|
|
||||||
makeSelectMetadataForUri,
|
makeSelectMetadataForUri,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import {
|
import {
|
||||||
makeSelectFileInfoForUri,
|
makeSelectFileInfoForUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
|
||||||
makeSelectFetchingAvailabilityForUri,
|
|
||||||
makeSelectAvailabilityForUri,
|
|
||||||
} from 'selectors/availability'
|
|
||||||
import {
|
import {
|
||||||
selectObscureNsfw,
|
selectObscureNsfw,
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
import {
|
import {
|
||||||
makeSelectResolvingUri,
|
makeSelectIsResolvingForUri,
|
||||||
} from 'selectors/content'
|
} from 'selectors/content'
|
||||||
import FileTile from './view'
|
import FileTile from './view'
|
||||||
|
|
||||||
const makeSelect = () => {
|
const makeSelect = () => {
|
||||||
const selectClaimForUri = makeSelectClaimForUri()
|
const selectClaimForUri = makeSelectClaimForUri()
|
||||||
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
const selectFileInfoForUri = makeSelectFileInfoForUri()
|
||||||
const selectFetchingAvailabilityForUri = makeSelectFetchingAvailabilityForUri()
|
|
||||||
const selectAvailabilityForUri = makeSelectAvailabilityForUri()
|
|
||||||
const selectMetadataForUri = makeSelectMetadataForUri()
|
const selectMetadataForUri = makeSelectMetadataForUri()
|
||||||
const selectSourceForUri = makeSelectSourceForUri()
|
const selectResolvingUri = makeSelectIsResolvingForUri()
|
||||||
const selectResolvingUri = makeSelectResolvingUri()
|
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const select = (state, props) => ({
|
||||||
claim: selectClaimForUri(state, props),
|
claim: selectClaimForUri(state, props),
|
||||||
fileInfo: selectFileInfoForUri(state, props),
|
fileInfo: selectFileInfoForUri(state, props),
|
||||||
fetchingAvailability: selectFetchingAvailabilityForUri(state, props),
|
|
||||||
selectAvailabilityForUri: selectAvailabilityForUri(state, props),
|
|
||||||
obscureNsfw: selectObscureNsfw(state),
|
obscureNsfw: selectObscureNsfw(state),
|
||||||
metadata: selectMetadataForUri(state, props),
|
metadata: selectMetadataForUri(state, props),
|
||||||
source: selectSourceForUri(state, props),
|
|
||||||
isResolvingUri: selectResolvingUri(state, props),
|
isResolvingUri: selectResolvingUri(state, props),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ class FileTile extends React.Component {
|
||||||
} else if (isResolvingUri) {
|
} else if (isResolvingUri) {
|
||||||
description = "Loading..."
|
description = "Loading..."
|
||||||
} else if (showEmpty === FileTile.SHOW_EMPTY_PUBLISH) {
|
} else if (showEmpty === FileTile.SHOW_EMPTY_PUBLISH) {
|
||||||
onClick = () => navigate('/publish')
|
onClick = () => navigate('/publish', { })
|
||||||
description = <span className="empty">
|
description = <span className="empty">
|
||||||
This location is unused. { ' ' }
|
This location is unused. { ' ' }
|
||||||
{ isClaimable && <span className="button-text">Put something here!</span> }
|
{ isClaimable && <span className="button-text">Put something here!</span> }
|
||||||
|
|
|
@ -2,14 +2,13 @@ import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import Router from './view.jsx';
|
import Router from './view.jsx';
|
||||||
import {
|
import {
|
||||||
selectCurrentPage
|
selectCurrentPage,
|
||||||
|
selectCurrentParams,
|
||||||
} from 'selectors/app.js';
|
} from 'selectors/app.js';
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
|
params: selectCurrentParams(state),
|
||||||
currentPage: selectCurrentPage(state)
|
currentPage: selectCurrentPage(state)
|
||||||
})
|
})
|
||||||
|
|
||||||
const perform = {
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(select, null)(Router);
|
export default connect(select, null)(Router);
|
||||||
|
|
|
@ -25,25 +25,26 @@ const route = (page, routesMap) => {
|
||||||
const Router = (props) => {
|
const Router = (props) => {
|
||||||
const {
|
const {
|
||||||
currentPage,
|
currentPage,
|
||||||
|
params,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return route(currentPage, {
|
return route(currentPage, {
|
||||||
'settings': <SettingsPage {...props} />,
|
'settings': <SettingsPage {...params} />,
|
||||||
'help': <HelpPage {...props} />,
|
'help': <HelpPage {...params} />,
|
||||||
'report': <ReportPage {...props} />,
|
'report': <ReportPage {...params} />,
|
||||||
'downloaded': <FileListDownloaded {...props} />,
|
'downloaded': <FileListDownloaded {...params} />,
|
||||||
'published': <FileListPublished {...props} />,
|
'published': <FileListPublished {...params} />,
|
||||||
'start': <StartPage {...props} />,
|
'start': <StartPage {...params} />,
|
||||||
'wallet': <WalletPage {...props} />,
|
'wallet': <WalletPage {...params} />,
|
||||||
'send': <WalletPage {...props} />,
|
'send': <WalletPage {...params} />,
|
||||||
'receive': <WalletPage {...props} />,
|
'receive': <WalletPage {...params} />,
|
||||||
'show': <ShowPage {...props} />,
|
'show': <ShowPage {...params} />,
|
||||||
'channel': <ChannelPage {...props} />,
|
'channel': <ChannelPage {...params} />,
|
||||||
'publish': <PublishPage {...props} />,
|
'publish': <PublishPage {...params} />,
|
||||||
'developer': <DeveloperPage {...props} />,
|
'developer': <DeveloperPage {...params} />,
|
||||||
'discover': <DiscoverPage {...props} />,
|
'discover': <DiscoverPage {...params} />,
|
||||||
'rewards': <RewardsPage {...props} />,
|
'rewards': <RewardsPage {...params} />,
|
||||||
'search': <SearchPage {...props} />,
|
'search': <SearchPage {...params} />,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,30 +13,42 @@ import {
|
||||||
doLoadVideo,
|
doLoadVideo,
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import {
|
import {
|
||||||
selectLoadingCurrentUri,
|
makeSelectMetadataForUri
|
||||||
selectCurrentUriFileReadyToPlay,
|
} from 'selectors/claims'
|
||||||
selectCurrentUriIsPlaying,
|
import {
|
||||||
selectCurrentUriFileInfo,
|
makeSelectFileInfoForUri,
|
||||||
selectDownloadingCurrentUri,
|
makeSelectLoadingForUri,
|
||||||
|
makeSelectDownloadingForUri,
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriCostInfo,
|
makeSelectCostInfoForUri,
|
||||||
} from 'selectors/cost_info'
|
} from 'selectors/cost_info'
|
||||||
import Video from './view'
|
import Video from './view'
|
||||||
|
|
||||||
const select = (state) => ({
|
|
||||||
costInfo: selectCurrentUriCostInfo(state),
|
const makeSelect = () => {
|
||||||
fileInfo: selectCurrentUriFileInfo(state),
|
const selectCostInfo = makeSelectCostInfoForUri()
|
||||||
modal: selectCurrentModal(state),
|
const selectFileInfo = makeSelectFileInfoForUri()
|
||||||
isLoading: selectLoadingCurrentUri(state),
|
const selectIsLoading = makeSelectLoadingForUri()
|
||||||
readyToPlay: selectCurrentUriFileReadyToPlay(state),
|
const selectIsDownloading = makeSelectDownloadingForUri()
|
||||||
isDownloading: selectDownloadingCurrentUri(state),
|
const selectMetadata = makeSelectMetadataForUri()
|
||||||
})
|
|
||||||
|
const select = (state, props) => ({
|
||||||
|
costInfo: selectCostInfo(state, props),
|
||||||
|
fileInfo: selectFileInfo(state, props),
|
||||||
|
metadata: selectMetadata(state, props),
|
||||||
|
modal: selectCurrentModal(state),
|
||||||
|
isLoading: selectIsLoading(state, props),
|
||||||
|
isDownloading: selectIsDownloading(state, props),
|
||||||
|
})
|
||||||
|
|
||||||
|
return select
|
||||||
|
}
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
loadVideo: () => dispatch(doLoadVideo()),
|
loadVideo: (uri) => dispatch(doLoadVideo(uri)),
|
||||||
watchVideo: (elem) => dispatch(doWatchVideo()),
|
watchVideo: (uri) => dispatch(doWatchVideo(uri)),
|
||||||
closeModal: () => dispatch(doCloseModal()),
|
closeModal: () => dispatch(doCloseModal()),
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(select, perform)(Video)
|
export default connect(makeSelect, perform)(Video)
|
|
@ -1,17 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
|
||||||
Icon,
|
|
||||||
Thumbnail,
|
|
||||||
} from 'component/common';
|
|
||||||
import FilePrice from 'component/filePrice'
|
import FilePrice from 'component/filePrice'
|
||||||
import Link from 'component/link';
|
import Link from 'component/link';
|
||||||
import Modal from 'component/modal';
|
import Modal from 'component/modal';
|
||||||
|
|
||||||
class WatchLink extends React.Component {
|
class VideoPlayButton extends React.Component {
|
||||||
confirmPurchaseClick() {
|
confirmPurchaseClick() {
|
||||||
this.props.closeModal()
|
this.props.closeModal()
|
||||||
this.props.startPlaying()
|
this.props.startPlaying()
|
||||||
this.props.loadVideo()
|
this.props.loadVideo(this.props.uri)
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -32,9 +28,17 @@ class WatchLink extends React.Component {
|
||||||
fileInfo,
|
fileInfo,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
|
/*
|
||||||
|
title={
|
||||||
|
isLoading ? "Video is Loading" :
|
||||||
|
!costInfo ? "Waiting on cost info..." :
|
||||||
|
fileInfo === undefined ? "Waiting on file info..." : ""
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return (<div>
|
return (<div>
|
||||||
<Link button={ button ? button : null }
|
<Link button={ button ? button : null }
|
||||||
disabled={isLoading || !costInfo || costInfo.cost == undefined || fileInfo === undefined}
|
disabled={isLoading || !costInfo || costInfo.cost === undefined || fileInfo === undefined}
|
||||||
label={label ? label : ""}
|
label={label ? label : ""}
|
||||||
className="video__play-button"
|
className="video__play-button"
|
||||||
icon="icon-play"
|
icon="icon-play"
|
||||||
|
@ -68,7 +72,7 @@ class Video extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onWatchClick() {
|
onWatchClick() {
|
||||||
this.props.watchVideo().then(() => {
|
this.props.watchVideo(this.props.uri).then(() => {
|
||||||
if (!this.props.modal) {
|
if (!this.props.modal) {
|
||||||
this.setState({
|
this.setState({
|
||||||
isPlaying: true
|
isPlaying: true
|
||||||
|
@ -85,8 +89,6 @@ class Video extends React.Component {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
readyToPlay = false,
|
|
||||||
thumbnail,
|
|
||||||
metadata,
|
metadata,
|
||||||
isLoading,
|
isLoading,
|
||||||
isDownloading,
|
isDownloading,
|
||||||
|
@ -105,14 +107,14 @@ class Video extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"video " + this.props.className + (isPlaying && readyToPlay ? " video--active" : " video--hidden")}>{
|
<div className={"video " + this.props.className + (isPlaying && fileInfo.isReadyToPlay ? " video--active" : " video--hidden")}>{
|
||||||
isPlaying ?
|
isPlaying ?
|
||||||
!readyToPlay ?
|
(!fileInfo.isReadyToPlay ?
|
||||||
<span>this is the world's worst loading screen and we shipped our software with it anyway... <br /><br />{loadStatusMessage}</span> :
|
<span>this is the world's worst loading screen and we shipped our software with it anyway... <br /><br />{loadStatusMessage}</span> :
|
||||||
<VideoPlayer downloadPath={fileInfo.download_path} /> :
|
<VideoPlayer downloadPath={fileInfo.download_path} />) :
|
||||||
<div className="video__cover" style={{backgroundImage: 'url("' + metadata.thumbnail + '")'}}>
|
<div className="video__cover" style={{backgroundImage: 'url("' + metadata.thumbnail + '")'}}>
|
||||||
<WatchLink icon="icon-play" onWatchClick={this.onWatchClick.bind(this)}
|
<VideoPlayButton onWatchClick={this.onWatchClick.bind(this)}
|
||||||
startPlaying={this.startPlaying.bind(this)} {...this.props}></WatchLink>
|
startPlaying={this.startPlaying.bind(this)} {...this.props} />
|
||||||
</div>
|
</div>
|
||||||
}</div>
|
}</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -642,7 +642,6 @@ lbry.claim_list_mine = function(params={}) {
|
||||||
const claimCacheKey = 'resolve_claim_cache';
|
const claimCacheKey = 'resolve_claim_cache';
|
||||||
lbry._claimCache = getSession(claimCacheKey, {});
|
lbry._claimCache = getSession(claimCacheKey, {});
|
||||||
lbry.resolve = function(params={}) {
|
lbry.resolve = function(params={}) {
|
||||||
console.log('resolve: ' + params.uri);
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!params.uri) {
|
if (!params.uri) {
|
||||||
throw "Resolve has hacked cache on top of it that requires a URI"
|
throw "Resolve has hacked cache on top of it that requires a URI"
|
||||||
|
|
|
@ -36,7 +36,9 @@ window.addEventListener('popstate', (event) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
ipcRenderer.on('open-uri-requested', (event, uri) => {
|
ipcRenderer.on('open-uri-requested', (event, uri) => {
|
||||||
console.log('FIX ME do magic dispatch');
|
if (uri) {
|
||||||
|
console.log('FIX ME do magic dispatch: ' + uri);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const initialState = app.store.getState();
|
const initialState = app.store.getState();
|
||||||
|
|
|
@ -3,25 +3,21 @@ import {
|
||||||
connect
|
connect
|
||||||
} from 'react-redux'
|
} from 'react-redux'
|
||||||
import {
|
import {
|
||||||
doFetchChannelClaims
|
doFetchClaimsByChannel
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import {
|
import {
|
||||||
selectCurrentUri,
|
makeSelectClaimsForChannel
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
|
||||||
selectCurrentUriClaim,
|
|
||||||
selectCurrentUriClaims,
|
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import ChannelPage from './view'
|
import ChannelPage from './view'
|
||||||
|
//
|
||||||
const select = (state) => ({
|
// const select = (state) => ({
|
||||||
uri: selectCurrentUri(state),
|
// uri: selectCurrentUri(state),
|
||||||
claim: selectCurrentUriClaim(state),
|
// claim: selectCurrentUriClaim(state),
|
||||||
claims: selectCurrentUriClaims(state)
|
// claims: selectCurrentUriClaims(state)
|
||||||
})
|
// })
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
fetchClaims: (uri) => dispatch(doFetchChannelClaims(uri))
|
fetchClaims: (uri) => dispatch(doFetchClaimsByChannel(uri))
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(select, perform)(ChannelPage)
|
export default connect(null, perform)(ChannelPage)
|
||||||
|
|
|
@ -3,33 +3,41 @@ import {
|
||||||
connect
|
connect
|
||||||
} from 'react-redux'
|
} from 'react-redux'
|
||||||
import {
|
import {
|
||||||
doFetchCurrentUriFileInfo
|
doFetchFileInfo,
|
||||||
} from 'actions/file_info'
|
} from 'actions/file_info'
|
||||||
import {
|
import {
|
||||||
selectCurrentUri,
|
makeSelectFileInfoForUri,
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
|
||||||
selectCurrentUriFileInfo,
|
|
||||||
selectCurrentUriIsDownloaded,
|
|
||||||
} from 'selectors/file_info'
|
} from 'selectors/file_info'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriClaim,
|
makeSelectClaimForUri,
|
||||||
|
makeSelectContentTypeForUri,
|
||||||
|
makeSelectMetadataForUri,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriCostInfo,
|
makeSelectCostInfoForUri,
|
||||||
} from 'selectors/cost_info'
|
} from 'selectors/cost_info'
|
||||||
import FilePage from './view'
|
import FilePage from './view'
|
||||||
|
|
||||||
const select = (state) => ({
|
const makeSelect = () => {
|
||||||
claim: selectCurrentUriClaim(state),
|
const selectClaim = makeSelectClaimForUri(),
|
||||||
uri: selectCurrentUri(state),
|
selectContentType = makeSelectContentTypeForUri(),
|
||||||
isDownloaded: selectCurrentUriIsDownloaded(state),
|
selectFileInfo = makeSelectFileInfoForUri(),
|
||||||
fileInfo: selectCurrentUriFileInfo(state),
|
selectCostInfo = makeSelectCostInfoForUri(),
|
||||||
costInfo: selectCurrentUriCostInfo(state),
|
selectMetadata = makeSelectMetadataForUri()
|
||||||
})
|
|
||||||
|
const select = (state, props) => ({
|
||||||
|
claim: selectClaim(state, props),
|
||||||
|
contentType: selectContentType(state, props),
|
||||||
|
costInfo: selectCostInfo(state, props),
|
||||||
|
metadata: selectMetadata(state, props),
|
||||||
|
fileInfo: selectFileInfo(state, props)
|
||||||
|
})
|
||||||
|
|
||||||
|
return select
|
||||||
|
}
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
fetchFileInfo: () => dispatch(doFetchCurrentUriFileInfo())
|
fetchFileInfo: (uri) => dispatch(doFetchFileInfo(uri))
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(select, perform)(FilePage)
|
export default connect(makeSelect, perform)(FilePage)
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import lbry from 'lbry.js';
|
import lbry from 'lbry.js';
|
||||||
import lighthouse from 'lighthouse.js';
|
|
||||||
import lbryuri from 'lbryuri.js';
|
import lbryuri from 'lbryuri.js';
|
||||||
import Video from 'component/video'
|
import Video from 'component/video'
|
||||||
import {
|
import {
|
||||||
TruncatedText,
|
|
||||||
Thumbnail,
|
Thumbnail,
|
||||||
BusyMessage,
|
|
||||||
} from 'component/common';
|
} from 'component/common';
|
||||||
import FilePrice from 'component/filePrice'
|
import FilePrice from 'component/filePrice'
|
||||||
import FileActions from 'component/fileActions';
|
import FileActions from 'component/fileActions';
|
||||||
|
@ -57,64 +54,50 @@ class FilePage extends React.Component{
|
||||||
|
|
||||||
fetchFileInfo(props) {
|
fetchFileInfo(props) {
|
||||||
if (props.fileInfo === undefined) {
|
if (props.fileInfo === undefined) {
|
||||||
props.fetchFileInfo()
|
props.fetchFileInfo(props.uri)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
claim,
|
claim,
|
||||||
navigate,
|
metadata,
|
||||||
claim: {
|
contentType,
|
||||||
txid,
|
|
||||||
nout,
|
|
||||||
has_signature: hasSignature,
|
|
||||||
signature_is_valid: signatureIsValid,
|
|
||||||
value,
|
|
||||||
value: {
|
|
||||||
stream,
|
|
||||||
stream: {
|
|
||||||
metadata,
|
|
||||||
source,
|
|
||||||
metadata: {
|
|
||||||
title,
|
|
||||||
} = {},
|
|
||||||
source: {
|
|
||||||
contentType,
|
|
||||||
} = {},
|
|
||||||
} = {},
|
|
||||||
} = {},
|
|
||||||
},
|
|
||||||
uri,
|
uri,
|
||||||
isDownloaded,
|
|
||||||
fileInfo,
|
fileInfo,
|
||||||
costInfo,
|
|
||||||
costInfo: {
|
|
||||||
cost,
|
|
||||||
includesData: costIncludesData,
|
|
||||||
} = {},
|
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const outpoint = txid + ':' + nout;
|
if (!claim || !metadata) {
|
||||||
const uriLookupComplete = !!claim && Object.keys(claim).length
|
return <span className="empty">Empty claim or metadata info.</span>
|
||||||
|
}
|
||||||
|
|
||||||
|
const {
|
||||||
|
txid,
|
||||||
|
nout,
|
||||||
|
has_signature: hasSignature,
|
||||||
|
signature_is_valid: signatureIsValid,
|
||||||
|
value
|
||||||
|
} = claim
|
||||||
|
|
||||||
|
const outpoint = txid + ':' + nout
|
||||||
|
const title = metadata.title
|
||||||
const channelUriObj = lbryuri.parse(uri)
|
const channelUriObj = lbryuri.parse(uri)
|
||||||
delete channelUriObj.path;
|
delete channelUriObj.path;
|
||||||
delete channelUriObj.contentName;
|
delete channelUriObj.contentName;
|
||||||
const channelUri = signatureIsValid && hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null;
|
const channelUri = signatureIsValid && hasSignature && channelUriObj.isChannel ? lbryuri.build(channelUriObj, false) : null
|
||||||
const uriIndicator = <UriIndicator uri={uri} />
|
const uriIndicator = <UriIndicator uri={uri} />
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="main--single-column">
|
<main className="main--single-column">
|
||||||
<section className="show-page-media">
|
<section className="show-page-media">
|
||||||
{ contentType && contentType.startsWith('video/') ?
|
{ contentType && contentType.startsWith('video/') ?
|
||||||
<Video className="video-embedded" uri={uri} metadata={metadata} outpoint={outpoint} /> :
|
<Video className="video-embedded" uri={uri} /> :
|
||||||
(metadata && metadata.thumbnail ? <Thumbnail src={metadata.thumbnail} /> : <Thumbnail />) }
|
(metadata && metadata.thumbnail ? <Thumbnail src={metadata.thumbnail} /> : <Thumbnail />) }
|
||||||
</section>
|
</section>
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="card__inner">
|
<div className="card__inner">
|
||||||
<div className="card__title-identity">
|
<div className="card__title-identity">
|
||||||
{isDownloaded === false
|
{!fileInfo || fileInfo.written_bytes <= 0
|
||||||
? <span style={{float: "right"}}><FilePrice uri={lbryuri.normalize(uri)} /></span>
|
? <span style={{float: "right"}}><FilePrice uri={lbryuri.normalize(uri)} /></span>
|
||||||
: null}<h1>{title}</h1>
|
: null}<h1>{title}</h1>
|
||||||
<div className="card__subtitle">
|
<div className="card__subtitle">
|
||||||
|
@ -123,7 +106,8 @@ class FilePage extends React.Component{
|
||||||
uriIndicator}
|
uriIndicator}
|
||||||
</div>
|
</div>
|
||||||
<div className="card__actions">
|
<div className="card__actions">
|
||||||
<FileActions uri={uri} /></div>
|
<FileActions uri={uri} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="card__content card__subtext card__subtext card__subtext--allow-newlines">
|
<div className="card__content card__subtext card__subtext card__subtext--allow-newlines">
|
||||||
{metadata && metadata.description}
|
{metadata && metadata.description}
|
||||||
|
@ -131,8 +115,7 @@ class FilePage extends React.Component{
|
||||||
</div>
|
</div>
|
||||||
{ metadata ?
|
{ metadata ?
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
<FormatItem metadata={metadata} contentType={contentType} cost={cost} uri={uri} outpoint={outpoint}
|
<FormatItem metadata={metadata} contentType={contentType} />
|
||||||
costIncludesData={costIncludesData} />
|
|
||||||
</div> : '' }
|
</div> : '' }
|
||||||
<div className="card__content">
|
<div className="card__content">
|
||||||
<Link href="https://lbry.io/dmca" label="report" className="button-text-help" />
|
<Link href="https://lbry.io/dmca" label="report" className="button-text-help" />
|
||||||
|
|
|
@ -6,26 +6,27 @@ import {
|
||||||
doResolveUri,
|
doResolveUri,
|
||||||
} from 'actions/content'
|
} from 'actions/content'
|
||||||
import {
|
import {
|
||||||
selectCurrentUri,
|
makeSelectClaimForUri,
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
|
||||||
selectCurrentUriClaim,
|
|
||||||
selectCurrentUriChannelClaim,
|
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
import {
|
import {
|
||||||
selectCurrentUriIsResolving,
|
makeSelectIsResolvingForUri,
|
||||||
} from 'selectors/content'
|
} from 'selectors/content'
|
||||||
import ShowPage from './view'
|
import ShowPage from './view'
|
||||||
|
|
||||||
const select = (state, props) => ({
|
const makeSelect = () => {
|
||||||
channelClaim: selectCurrentUriChannelClaim(state),
|
const selectClaim = makeSelectClaimForUri(),
|
||||||
claim: selectCurrentUriClaim(state),
|
selectIsResolving = makeSelectIsResolvingForUri();
|
||||||
uri: selectCurrentUri(state),
|
|
||||||
isResolvingUri: selectCurrentUriIsResolving(state)
|
const select = (state, props) => ({
|
||||||
})
|
claim: selectClaim(state, props),
|
||||||
|
isResolvingUri: selectIsResolving(state, props)
|
||||||
|
})
|
||||||
|
|
||||||
|
return select
|
||||||
|
}
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
const perform = (dispatch) => ({
|
||||||
resolveUri: (uri) => dispatch(doResolveUri(uri))
|
resolveUri: (uri) => dispatch(doResolveUri(uri))
|
||||||
})
|
})
|
||||||
|
|
||||||
export default connect(select, perform)(ShowPage)
|
export default connect(makeSelect, perform)(ShowPage)
|
||||||
|
|
|
@ -28,7 +28,6 @@ class ShowPage extends React.Component{
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
channelClaim,
|
|
||||||
claim,
|
claim,
|
||||||
uri,
|
uri,
|
||||||
isResolvingUri,
|
isResolvingUri,
|
||||||
|
@ -36,7 +35,7 @@ class ShowPage extends React.Component{
|
||||||
|
|
||||||
let innerContent = "";
|
let innerContent = "";
|
||||||
|
|
||||||
if (isResolvingUri || claim === null) {
|
if (isResolvingUri || !claim) {
|
||||||
innerContent = <section className="card">
|
innerContent = <section className="card">
|
||||||
<div className="card__inner">
|
<div className="card__inner">
|
||||||
<div className="card__title-identity"><h1>{uri}</h1></div>
|
<div className="card__title-identity"><h1>{uri}</h1></div>
|
||||||
|
@ -47,11 +46,12 @@ class ShowPage extends React.Component{
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
}
|
}
|
||||||
else if (channelClaim && claim && channelClaim.txid && channelClaim.txid === claim.txid) {
|
else if (claim.name.length && claim.name[0] === '@') {
|
||||||
innerContent = <ChannelPage claim={claim} />
|
innerContent = "channel"
|
||||||
|
// innerContent = <ChannelPage claim={claim} />
|
||||||
}
|
}
|
||||||
else if (claim) {
|
else if (claim) {
|
||||||
innerContent = <FilePage />
|
innerContent = <FilePage uri={uri} />
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -9,7 +9,6 @@ const defaultState = {
|
||||||
upgradeSkipped: sessionStorage.getItem('upgradeSkipped'),
|
upgradeSkipped: sessionStorage.getItem('upgradeSkipped'),
|
||||||
daemonReady: false,
|
daemonReady: false,
|
||||||
obscureNsfw: !lbry.getClientSetting('showNsfw'),
|
obscureNsfw: !lbry.getClientSetting('showNsfw'),
|
||||||
hidePrice: false,
|
|
||||||
hasSignature: false,
|
hasSignature: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,8 @@ reducers[types.FETCH_AVAILABILITY_STARTED] = function(state, action) {
|
||||||
uri,
|
uri,
|
||||||
} = action.data
|
} = action.data
|
||||||
const newFetching = Object.assign({}, state.fetching)
|
const newFetching = Object.assign({}, state.fetching)
|
||||||
const newByUri = Object.assign({}, newFetching.byUri)
|
|
||||||
|
|
||||||
newByUri[uri] = true
|
newFetching[uri] = true
|
||||||
newFetching.byUri = newByUri
|
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
fetching: newFetching,
|
fetching: newFetching,
|
||||||
|
@ -24,12 +22,11 @@ reducers[types.FETCH_AVAILABILITY_COMPLETED] = function(state, action) {
|
||||||
uri,
|
uri,
|
||||||
availability,
|
availability,
|
||||||
} = action.data
|
} = action.data
|
||||||
|
|
||||||
const newFetching = Object.assign({}, state.fetching)
|
const newFetching = Object.assign({}, state.fetching)
|
||||||
const newFetchingByUri = Object.assign({}, newFetching.byUri)
|
|
||||||
const newAvailabilityByUri = Object.assign({}, state.byUri)
|
const newAvailabilityByUri = Object.assign({}, state.byUri)
|
||||||
|
|
||||||
delete newFetchingByUri[uri]
|
delete newFetching[uri]
|
||||||
newFetching.byUri = newFetchingByUri
|
|
||||||
newAvailabilityByUri[uri] = availability
|
newAvailabilityByUri[uri] = availability
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
|
|
|
@ -13,23 +13,22 @@ reducers[types.RESOLVE_URI_COMPLETED] = function(state, action) {
|
||||||
} = action.data
|
} = action.data
|
||||||
|
|
||||||
const newClaims = Object.assign({}, state.claimsByUri)
|
const newClaims = Object.assign({}, state.claimsByUri)
|
||||||
const newChannelClaims = Object.assign({}, state.channelClaimsByUri)
|
|
||||||
|
|
||||||
if (claim !== undefined) {
|
if (claim !== undefined) {
|
||||||
newClaims[uri] = claim
|
newClaims[uri] = claim
|
||||||
}
|
}
|
||||||
|
|
||||||
//This needs a sanity boost...
|
//This needs a sanity boost...
|
||||||
if (certificate !== undefined) {
|
if (certificate !== undefined && claim === undefined) {
|
||||||
newChannelClaims[uri] = certificate
|
const uriParts = lbryuri.parse(uri);
|
||||||
|
// newChannelClaims[uri] = certificate
|
||||||
if (claim === undefined) {
|
if (claim === undefined) {
|
||||||
newClaims[uri] = certificate
|
newClaims[uri] = certificate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
claimsByUri: newClaims,
|
claimsByUri: newClaims
|
||||||
channelClaimsByUri: newChannelClaims
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,10 +23,17 @@ reducers[types.FETCH_FILE_INFO_COMPLETED] = function(state, action) {
|
||||||
uri,
|
uri,
|
||||||
fileInfo,
|
fileInfo,
|
||||||
} = action.data
|
} = action.data
|
||||||
|
|
||||||
const newByUri = Object.assign({}, state.byUri)
|
const newByUri = Object.assign({}, state.byUri)
|
||||||
const newFetching = Object.assign({}, state.fetching)
|
const newFetching = Object.assign({}, state.fetching)
|
||||||
|
|
||||||
newByUri[uri] = fileInfo || {}
|
if (fileInfo) {
|
||||||
|
fileInfo.isReadyToPlay = fileInfo.written_bytes > 0
|
||||||
|
fileInfo.isDownloaded = fileInfo.completed && fileInfo.written_bytes > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
newByUri[uri] = fileInfo || null
|
||||||
|
|
||||||
delete newFetching[uri]
|
delete newFetching[uri]
|
||||||
|
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
|
|
|
@ -31,22 +31,10 @@ export const selectCurrentParams = createSelector(
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectCurrentUri = createSelector(
|
|
||||||
selectCurrentPath,
|
|
||||||
(path) => {
|
|
||||||
if (path.match(/=/)) {
|
|
||||||
return path.split('=')[1]
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectPageTitle = createSelector(
|
export const selectPageTitle = createSelector(
|
||||||
selectCurrentPage,
|
selectCurrentPage,
|
||||||
selectCurrentUri,
|
selectCurrentParams,
|
||||||
(page, uri) => {
|
(page, params) => {
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case 'search':
|
case 'search':
|
||||||
return 'Search'
|
return 'Search'
|
||||||
|
@ -62,7 +50,7 @@ export const selectPageTitle = createSelector(
|
||||||
case 'rewards':
|
case 'rewards':
|
||||||
return page.charAt(0).toUpperCase() + page.slice(1)
|
return page.charAt(0).toUpperCase() + page.slice(1)
|
||||||
case 'show':
|
case 'show':
|
||||||
return lbryuri.normalize(uri)
|
return lbryuri.normalize(params.uri)
|
||||||
case 'downloaded':
|
case 'downloaded':
|
||||||
return 'Downloads & Purchases'
|
return 'Downloads & Purchases'
|
||||||
case 'published':
|
case 'published':
|
||||||
|
@ -190,11 +178,6 @@ export const selectUpgradeDownloadItem = createSelector(
|
||||||
(state) => state.downloadItem
|
(state) => state.downloadItem
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectSearchTerm = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => state.searchTerm
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectError = createSelector(
|
export const selectError = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.error
|
(state) => state.error
|
||||||
|
@ -210,11 +193,6 @@ export const selectObscureNsfw = createSelector(
|
||||||
(state) => !!state.obscureNsfw
|
(state) => !!state.obscureNsfw
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectHidePrice = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => !!state.hidePrice
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectHasSignature = createSelector(
|
export const selectHasSignature = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => !!state.hasSignature
|
(state) => !!state.hasSignature
|
||||||
|
|
|
@ -4,7 +4,6 @@ import {
|
||||||
import {
|
import {
|
||||||
selectDaemonReady,
|
selectDaemonReady,
|
||||||
selectCurrentPage,
|
selectCurrentPage,
|
||||||
selectCurrentUri,
|
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
|
|
||||||
const _selectState = state => state.availability
|
const _selectState = state => state.availability
|
||||||
|
@ -14,29 +13,24 @@ export const selectAvailabilityByUri = createSelector(
|
||||||
(state) => state.byUri || {}
|
(state) => state.byUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const selectAvailabilityForUri = (state, props) => {
|
||||||
|
return selectAvailabilityByUri(state)[props.uri]
|
||||||
|
}
|
||||||
|
|
||||||
|
export const makeSelectIsAvailableForUri = () => {
|
||||||
|
return createSelector(
|
||||||
|
selectAvailabilityForUri,
|
||||||
|
(availability) => availability === undefined ? undefined : availability > 0
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const selectFetchingAvailability = createSelector(
|
export const selectFetchingAvailability = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.fetching || {}
|
(state) => state.fetching || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectFetchingAvailabilityByUri = createSelector(
|
|
||||||
selectFetchingAvailability,
|
|
||||||
(fetching) => fetching.byUri || {}
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectAvailabilityForUri = (state, props) => {
|
|
||||||
return selectAvailabilityByUri(state)[props.uri]
|
|
||||||
}
|
|
||||||
|
|
||||||
export const makeSelectAvailabilityForUri = () => {
|
|
||||||
return createSelector(
|
|
||||||
selectAvailabilityForUri,
|
|
||||||
(availability) => availability
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectFetchingAvailabilityForUri = (state, props) => {
|
const selectFetchingAvailabilityForUri = (state, props) => {
|
||||||
return selectFetchingAvailabilityByUri(state)[props.uri]
|
return selectFetchingAvailability(state)[props.uri]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeSelectFetchingAvailabilityForUri = () => {
|
export const makeSelectFetchingAvailabilityForUri = () => {
|
||||||
|
@ -45,15 +39,3 @@ export const makeSelectFetchingAvailabilityForUri = () => {
|
||||||
(fetching) => fetching
|
(fetching) => fetching
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const selectFetchingAvailabilityForCurrentUri = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectFetchingAvailabilityByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectAvailabilityForCurrentUri = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectAvailabilityByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
|
@ -2,9 +2,6 @@ import {
|
||||||
createSelector,
|
createSelector,
|
||||||
} from 'reselect'
|
} from 'reselect'
|
||||||
import lbryuri from 'lbryuri'
|
import lbryuri from 'lbryuri'
|
||||||
import {
|
|
||||||
selectCurrentUri,
|
|
||||||
} from 'selectors/app'
|
|
||||||
|
|
||||||
export const _selectState = state => state.claims || {}
|
export const _selectState = state => state.claims || {}
|
||||||
|
|
||||||
|
@ -13,40 +10,21 @@ export const selectClaimsByUri = createSelector(
|
||||||
(state) => state.claimsByUri || {}
|
(state) => state.claimsByUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectCurrentUriClaim = createSelector(
|
export const selectAllClaimsByChannel = createSelector(
|
||||||
selectCurrentUri,
|
|
||||||
selectClaimsByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectChannelClaimsByUri = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => state.channelClaimsByUri || {}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectCurrentUriChannelClaim = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectChannelClaimsByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectCurrentUriClaimOutpoint = createSelector(
|
|
||||||
selectCurrentUriClaim,
|
|
||||||
(claim) => {
|
|
||||||
return claim ? `${claim.txid}:${claim.nout}` : null
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectClaimsByChannel = createSelector(
|
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.claimsByChannel || {}
|
(state) => state.claimsByChannel || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectCurrentUriClaims = createSelector(
|
export const selectClaimsForChannel = (state, props) => {
|
||||||
selectCurrentUri,
|
return selectAllClaimsByChannel(state)[props.uri]
|
||||||
selectClaimsByChannel,
|
}
|
||||||
(uri, byChannel) => byChannel[uri]
|
|
||||||
)
|
export const makeSelectClaimsForChannel = () => {
|
||||||
|
return createSelector(
|
||||||
|
selectClaimsForChannel,
|
||||||
|
(claim) => claim
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const selectClaimForUri = (state, props) => {
|
const selectClaimForUri = (state, props) => {
|
||||||
const uri = lbryuri.normalize(props.uri)
|
const uri = lbryuri.normalize(props.uri)
|
||||||
|
@ -64,7 +42,7 @@ const selectMetadataForUri = (state, props) => {
|
||||||
const claim = selectClaimForUri(state, props)
|
const claim = selectClaimForUri(state, props)
|
||||||
const metadata = claim && claim.value && claim.value.stream && claim.value.stream.metadata
|
const metadata = claim && claim.value && claim.value.stream && claim.value.stream.metadata
|
||||||
|
|
||||||
return metadata ? metadata : undefined
|
return metadata ? metadata : (claim === undefined ? undefined : null)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeSelectMetadataForUri = () => {
|
export const makeSelectMetadataForUri = () => {
|
||||||
|
@ -78,7 +56,7 @@ const selectSourceForUri = (state, props) => {
|
||||||
const claim = selectClaimForUri(state, props)
|
const claim = selectClaimForUri(state, props)
|
||||||
const source = claim && claim.value && claim.value.stream && claim.value.stream.source
|
const source = claim && claim.value && claim.value.stream && claim.value.stream.source
|
||||||
|
|
||||||
return source ? source : undefined
|
return source ? source : (claim === undefined ? undefined : null)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeSelectSourceForUri = () => {
|
export const makeSelectSourceForUri = () => {
|
||||||
|
@ -88,6 +66,13 @@ export const makeSelectSourceForUri = () => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const makeSelectContentTypeForUri = () => {
|
||||||
|
return createSelector(
|
||||||
|
selectSourceForUri,
|
||||||
|
(source) => source ? source.contentType : source
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export const selectMyClaims = createSelector(
|
export const selectMyClaims = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.mine || {}
|
(state) => state.mine || {}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { createSelector } from 'reselect'
|
||||||
import {
|
import {
|
||||||
selectDaemonReady,
|
selectDaemonReady,
|
||||||
selectCurrentPage,
|
selectCurrentPage,
|
||||||
selectCurrentUri,
|
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
|
|
||||||
export const _selectState = state => state.content || {}
|
export const _selectState = state => state.content || {}
|
||||||
|
@ -17,10 +16,6 @@ export const selectFetchingFeaturedUris = createSelector(
|
||||||
(state) => !!state.fetchingFeaturedContent
|
(state) => !!state.fetchingFeaturedContent
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectFetchingFileInfos = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => state.fetchingFileInfos || {}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectFetchingDownloadedContent = createSelector(
|
export const selectFetchingDownloadedContent = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
|
@ -47,24 +42,16 @@ export const selectPublishedContent = createSelector(
|
||||||
(state) => state.publishedContent || {}
|
(state) => state.publishedContent || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const selectResolvingUris = createSelector(
|
||||||
export const selectResolvingUris = createSelector(
|
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.resolvingUris || []
|
(state) => state.resolvingUris || []
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
export const selectCurrentUriIsResolving = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectResolvingUris,
|
|
||||||
(uri, resolvingUris) => resolvingUris.indexOf(uri) != -1
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectResolvingUri = (state, props) => {
|
const selectResolvingUri = (state, props) => {
|
||||||
return selectResolvingUris(state).indexOf(props.uri) != -1
|
return selectResolvingUris(state).indexOf(props.uri) != -1
|
||||||
}
|
}
|
||||||
|
|
||||||
export const makeSelectResolvingUri = () => {
|
export const makeSelectIsResolvingForUri = () => {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
selectResolvingUri,
|
selectResolvingUri,
|
||||||
(resolving) => resolving
|
(resolving) => resolving
|
||||||
|
|
|
@ -1,8 +1,4 @@
|
||||||
import { createSelector } from 'reselect'
|
import { createSelector } from 'reselect'
|
||||||
import {
|
|
||||||
selectCurrentUri,
|
|
||||||
selectCurrentPage,
|
|
||||||
} from 'selectors/app'
|
|
||||||
|
|
||||||
export const _selectState = state => state.costInfo || {}
|
export const _selectState = state => state.costInfo || {}
|
||||||
|
|
||||||
|
@ -11,24 +7,7 @@ export const selectAllCostInfoByUri = createSelector(
|
||||||
(state) => state.byUri || {}
|
(state) => state.byUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectCurrentUriCostInfo = createSelector(
|
export const selectCostInfoForUri = (state, props) => {
|
||||||
selectCurrentUri,
|
|
||||||
selectAllCostInfoByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectFetchingCostInfo = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => state.fetching || {}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectFetchingCurrentUriCostInfo = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectFetchingCostInfo,
|
|
||||||
(uri, byUri) => !!byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectCostInfoForUri = (state, props) => {
|
|
||||||
return selectAllCostInfoByUri(state)[props.uri]
|
return selectAllCostInfoByUri(state)[props.uri]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
import {
|
import {
|
||||||
createSelector,
|
createSelector,
|
||||||
} from 'reselect'
|
} from 'reselect'
|
||||||
import {
|
|
||||||
selectCurrentUri,
|
|
||||||
selectCurrentPage,
|
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
import {
|
||||||
selectMyClaimsOutpoints,
|
selectMyClaimsOutpoints,
|
||||||
} from 'selectors/claims'
|
} from 'selectors/claims'
|
||||||
|
@ -16,28 +12,6 @@ export const selectAllFileInfoByUri = createSelector(
|
||||||
(state) => state.byUri || {}
|
(state) => state.byUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectCurrentUriRawFileInfo = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectAllFileInfoByUri,
|
|
||||||
(uri, byUri) => byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectCurrentUriFileInfo = createSelector(
|
|
||||||
selectCurrentUriRawFileInfo,
|
|
||||||
(fileInfo) => fileInfo
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectFetchingFileInfo = createSelector(
|
|
||||||
_selectState,
|
|
||||||
(state) => state.fetching || {}
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectFetchingCurrentUriFileInfo = createSelector(
|
|
||||||
selectCurrentUri,
|
|
||||||
selectFetchingFileInfo,
|
|
||||||
(uri, byUri) => !!byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectDownloading = createSelector(
|
export const selectDownloading = createSelector(
|
||||||
_selectState,
|
_selectState,
|
||||||
(state) => state.downloading || {}
|
(state) => state.downloading || {}
|
||||||
|
@ -48,24 +22,7 @@ export const selectDownloadingByUri = createSelector(
|
||||||
(downloading) => downloading.byUri || {}
|
(downloading) => downloading.byUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectDownloadingCurrentUri = createSelector(
|
export const selectFileInfoForUri = (state, props) => {
|
||||||
selectCurrentUri,
|
|
||||||
selectDownloadingByUri,
|
|
||||||
(uri, byUri) => !!byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
export const selectCurrentUriIsDownloaded = createSelector(
|
|
||||||
selectCurrentUriFileInfo,
|
|
||||||
(fileInfo) => {
|
|
||||||
if (!fileInfo) return false
|
|
||||||
if (!fileInfo.completed) return false
|
|
||||||
if (!fileInfo.written_bytes > 0) return false
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectFileInfoForUri = (state, props) => {
|
|
||||||
return selectAllFileInfoByUri(state)[props.uri]
|
return selectAllFileInfoByUri(state)[props.uri]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,19 +55,6 @@ export const selectLoadingByUri = createSelector(
|
||||||
(loading) => loading.byUri || {}
|
(loading) => loading.byUri || {}
|
||||||
)
|
)
|
||||||
|
|
||||||
export const selectLoadingCurrentUri = createSelector(
|
|
||||||
selectLoadingByUri,
|
|
||||||
selectCurrentUri,
|
|
||||||
(byUri, uri) => !!byUri[uri]
|
|
||||||
)
|
|
||||||
|
|
||||||
// TODO make this smarter so it doesn't start playing and immediately freeze
|
|
||||||
// while downloading more.
|
|
||||||
export const selectCurrentUriFileReadyToPlay = createSelector(
|
|
||||||
selectCurrentUriFileInfo,
|
|
||||||
(fileInfo) => (fileInfo || {}).written_bytes > 0
|
|
||||||
)
|
|
||||||
|
|
||||||
const selectLoadingForUri = (state, props) => {
|
const selectLoadingForUri = (state, props) => {
|
||||||
const byUri = selectLoadingByUri(state)
|
const byUri = selectLoadingByUri(state)
|
||||||
return byUri[props.uri]
|
return byUri[props.uri]
|
||||||
|
|
|
@ -2,7 +2,6 @@ import { createSelector } from 'reselect'
|
||||||
import {
|
import {
|
||||||
selectPageTitle,
|
selectPageTitle,
|
||||||
selectCurrentPage,
|
selectCurrentPage,
|
||||||
selectCurrentUri
|
|
||||||
} from 'selectors/app'
|
} from 'selectors/app'
|
||||||
|
|
||||||
export const _selectState = state => state.search || {}
|
export const _selectState = state => state.search || {}
|
||||||
|
@ -43,8 +42,7 @@ export const selectWunderBarAddress = createSelector(
|
||||||
|
|
||||||
export const selectWunderBarIcon = createSelector(
|
export const selectWunderBarIcon = createSelector(
|
||||||
selectCurrentPage,
|
selectCurrentPage,
|
||||||
selectCurrentUri,
|
(page) => {
|
||||||
(page, uri) => {
|
|
||||||
switch (page) {
|
switch (page) {
|
||||||
case 'search':
|
case 'search':
|
||||||
return 'icon-search'
|
return 'icon-search'
|
||||||
|
|
Loading…
Reference in a new issue