@@ -36,7 +37,9 @@ class ChannelPage extends React.Component{
- {claims}
+ {claimsInChannel ?
+ claimsInChannel.map((claim) => )
+ : ''}
diff --git a/ui/js/page/fileListDownloaded/index.js b/ui/js/page/fileListDownloaded/index.js
index 7122ff5fd..101933bd1 100644
--- a/ui/js/page/fileListDownloaded/index.js
+++ b/ui/js/page/fileListDownloaded/index.js
@@ -3,11 +3,11 @@ import {
connect
} from 'react-redux'
import {
- doFetchDownloadedContent,
+ doFetchFileInfosAndPublishedClaims,
} from 'actions/file_info'
import {
- selectDownloadedFileInfo,
- selectFetchingDownloadedContent,
+ selectFileInfosDownloaded,
+ selectFileListDownloadedOrPublishedIsPending,
} from 'selectors/file_info'
import {
doNavigate,
@@ -15,13 +15,13 @@ import {
import FileListDownloaded from './view'
const select = (state) => ({
- downloadedContent: selectDownloadedFileInfo(state),
- fetching: selectFetchingDownloadedContent(state),
+ fileInfos: selectFileInfosDownloaded(state),
+ isPending: selectFileListDownloadedOrPublishedIsPending(state),
})
const perform = (dispatch) => ({
navigate: (path) => dispatch(doNavigate(path)),
- fetchFileListDownloaded: () => dispatch(doFetchDownloadedContent()),
+ fetchFileInfosDownloaded: () => dispatch(doFetchFileInfosAndPublishedClaims()),
})
export default connect(select, perform)(FileListDownloaded)
diff --git a/ui/js/page/fileListDownloaded/view.jsx b/ui/js/page/fileListDownloaded/view.jsx
index 2c041a267..670b27191 100644
--- a/ui/js/page/fileListDownloaded/view.jsx
+++ b/ui/js/page/fileListDownloaded/view.jsx
@@ -12,21 +12,21 @@ import SubHeader from 'component/subHeader'
class FileListDownloaded extends React.Component {
componentWillMount() {
- this.props.fetchFileListDownloaded()
+ this.props.fetchFileInfosDownloaded()
}
render() {
const {
- downloadedContent,
- fetching,
+ fileInfos,
+ isPending,
navigate,
} = this.props
let content
- if (downloadedContent && downloadedContent.length > 0) {
- content =
+ if (fileInfos && fileInfos.length > 0) {
+ content =
} else {
- if (fetching) {
+ if (isPending) {
content =
} else {
content =
You haven't downloaded anything from LBRY yet. Go navigate('/discover')} label="search for your first download" />!
diff --git a/ui/js/page/fileListPublished/index.js b/ui/js/page/fileListPublished/index.js
index 22f2b8736..fbf0bcb71 100644
--- a/ui/js/page/fileListPublished/index.js
+++ b/ui/js/page/fileListPublished/index.js
@@ -3,13 +3,11 @@ import {
connect
} from 'react-redux'
import {
- doFetchPublishedContent,
-} from 'actions/content'
+ doFetchFileInfosAndPublishedClaims,
+} from 'actions/file_info'
import {
- selectFetchingPublishedContent,
-} from 'selectors/content'
-import {
- selectPublishedFileInfo,
+ selectFileInfosPublished,
+ selectFileListDownloadedOrPublishedIsPending
} from 'selectors/file_info'
import {
doNavigate,
@@ -17,13 +15,13 @@ import {
import FileListPublished from './view'
const select = (state) => ({
- publishedContent: selectPublishedFileInfo(state),
- fetching: selectFetchingPublishedContent(state),
+ fileInfos: selectFileInfosPublished(state),
+ isPending: selectFileListDownloadedOrPublishedIsPending(state),
})
const perform = (dispatch) => ({
navigate: (path) => dispatch(doNavigate(path)),
- fetchFileListPublished: () => dispatch(doFetchPublishedContent()),
+ fetchFileListPublished: () => dispatch(doFetchFileInfosAndPublishedClaims()),
})
export default connect(select, perform)(FileListPublished)
diff --git a/ui/js/page/fileListPublished/view.jsx b/ui/js/page/fileListPublished/view.jsx
index 365aa061c..488a45086 100644
--- a/ui/js/page/fileListPublished/view.jsx
+++ b/ui/js/page/fileListPublished/view.jsx
@@ -3,7 +3,7 @@ import lbry from 'lbry.js';
import lbryuri from 'lbryuri.js';
import Link from 'component/link';
import {FormField} from 'component/form.js';
-import {FileTile} from 'component/fileTile';
+import FileTile from 'component/fileTile';
import rewards from 'rewards.js';
import lbryio from 'lbryio.js';
import {BusyMessage, Thumbnail} from 'component/common.js';
@@ -16,7 +16,7 @@ class FileListPublished extends React.Component {
}
componentDidUpdate() {
- if(this.props.publishedContent.length > 0) this._requestPublishReward()
+ if(this.props.fileInfos.length > 0) this._requestPublishReward()
}
_requestPublishReward() {
@@ -38,17 +38,17 @@ class FileListPublished extends React.Component {
render() {
const {
- publishedContent,
- fetching,
+ fileInfos,
+ isPending,
navigate,
} = this.props
let content
- if (publishedContent && publishedContent.length > 0) {
- content =
+ if (fileInfos && fileInfos.length > 0) {
+ content =
} else {
- if (fetching) {
+ if (isPending) {
content =
} else {
content =
You haven't downloaded anything from LBRY yet. Go navigate('/discover')} label="search for your first download" />!
diff --git a/ui/js/page/filePage/view.jsx b/ui/js/page/filePage/view.jsx
index 20b87a83f..72d95a276 100644
--- a/ui/js/page/filePage/view.jsx
+++ b/ui/js/page/filePage/view.jsx
@@ -61,10 +61,10 @@ class FilePage extends React.Component{
render() {
const {
claim,
+ fileInfo,
metadata,
contentType,
uri,
- fileInfo,
} = this.props
if (!claim || !metadata) {
diff --git a/ui/js/page/help/view.jsx b/ui/js/page/help/view.jsx
index c57c4d1f0..2d4f516a6 100644
--- a/ui/js/page/help/view.jsx
+++ b/ui/js/page/help/view.jsx
@@ -24,9 +24,6 @@ var HelpPage = React.createClass({
});
});
},
- componentDidMount: function() {
- document.title = "Help";
- },
render: function() {
let ver, osName, platform, newVerLink;
if (this.state.versionInfo) {
diff --git a/ui/js/page/publish/index.js b/ui/js/page/publish/index.js
index 29347b6ed..d083fd118 100644
--- a/ui/js/page/publish/index.js
+++ b/ui/js/page/publish/index.js
@@ -5,9 +5,13 @@ import {
import {
doNavigate,
} from 'actions/app'
+import {
+ selectMyClaims
+} from 'selectors/claims'
import PublishPage from './view'
const select = (state) => ({
+ myClaims: selectMyClaims(state)
})
const perform = (dispatch) => ({
diff --git a/ui/js/page/publish/view.jsx b/ui/js/page/publish/view.jsx
index cb0b152b6..73c0df9e6 100644
--- a/ui/js/page/publish/view.jsx
+++ b/ui/js/page/publish/view.jsx
@@ -1,5 +1,6 @@
import React from 'react';
import lbry from 'lbry';
+import lbryuri from 'lbryuri'
import {FormField, FormRow} from 'component/form.js';
import Link from 'component/link';
import rewards from 'rewards';
@@ -169,7 +170,7 @@ var PublishPage = React.createClass({
return;
}
- if (!lbry.nameIsValid(rawName, false)) {
+ if (!lbryuri.isValidName(rawName, false)) {
this.refs.name.showError('LBRY names must contain only letters, numbers and dashes.');
return;
}
@@ -182,50 +183,45 @@ var PublishPage = React.createClass({
myClaimExists: null,
});
- lbry.getMyClaim(name, (myClaimInfo) => {
+ const myClaimInfo = Object.values(this.props.myClaims).find(claim => claim.name === name)
+
+ this.setState({
+ myClaimExists: !!myClaimInfo,
+ });
+ lbry.resolve({uri: name}).then((claimInfo) => {
if (name != this.state.name) {
- // A new name has been typed already, so bail
return;
}
- this.setState({
- myClaimExists: !!myClaimInfo,
- });
- lbry.resolve({uri: name}).then((claimInfo) => {
- if (name != this.state.name) {
- return;
- }
-
- if (!claimInfo) {
- this.setState({
- nameResolved: false,
- });
- } else {
- const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
- const newState = {
- nameResolved: true,
- topClaimValue: parseFloat(claimInfo.claim.amount),
- myClaimExists: !!myClaimInfo,
- myClaimValue: myClaimInfo ? parseFloat(myClaimInfo.claim.amount) : null,
- myClaimMetadata: myClaimInfo ? myClaimInfo.value : null,
- topClaimIsMine: topClaimIsMine,
- };
-
- if (topClaimIsMine) {
- newState.bid = myClaimInfo.claim.amount;
- } else if (this.state.myClaimMetadata) {
- // Just changed away from a name we have a claim on, so clear pre-fill
- newState.bid = '';
- }
-
- this.setState(newState);
- }
- }, () => { // Assume an error means the name is available
+ if (!claimInfo) {
this.setState({
- name: name,
nameResolved: false,
- myClaimExists: false,
});
+ } else {
+ const topClaimIsMine = (myClaimInfo && myClaimInfo.claim.amount >= claimInfo.claim.amount);
+ const newState = {
+ nameResolved: true,
+ topClaimValue: parseFloat(claimInfo.claim.amount),
+ myClaimExists: !!myClaimInfo,
+ myClaimValue: myClaimInfo ? parseFloat(myClaimInfo.claim.amount) : null,
+ myClaimMetadata: myClaimInfo ? myClaimInfo.value : null,
+ topClaimIsMine: topClaimIsMine,
+ };
+
+ if (topClaimIsMine) {
+ newState.bid = myClaimInfo.claim.amount;
+ } else if (this.state.myClaimMetadata) {
+ // Just changed away from a name we have a claim on, so clear pre-fill
+ newState.bid = '';
+ }
+
+ this.setState(newState);
+ }
+ }, () => { // Assume an error means the name is available
+ this.setState({
+ name: name,
+ nameResolved: false,
+ myClaimExists: false,
});
});
},
@@ -287,7 +283,7 @@ var PublishPage = React.createClass({
handleNewChannelNameChange: function (event) {
const newChannelName = (event.target.value.startsWith('@') ? event.target.value : '@' + event.target.value);
- if (newChannelName.length > 1 && !lbry.nameIsValid(newChannelName.substr(1), false)) {
+ if (newChannelName.length > 1 && !lbryuri.isValidName(newChannelName.substr(1), false)) {
this.refs.newChannelName.showError('LBRY channel names must contain only letters, numbers and dashes.');
return;
} else {
diff --git a/ui/js/page/showPage/view.jsx b/ui/js/page/showPage/view.jsx
index 0d0b0da5e..96983139c 100644
--- a/ui/js/page/showPage/view.jsx
+++ b/ui/js/page/showPage/view.jsx
@@ -1,7 +1,9 @@
import React from 'react';
+import lbryuri from 'lbryuri'
import {
BusyMessage,
} from 'component/common';
+import ChannelPage from 'page/channel'
import FilePage from 'page/filePage'
class ShowPage extends React.Component{
@@ -21,8 +23,6 @@ class ShowPage extends React.Component{
uri,
} = props
- console.log('show page resolve ' + uri)
- console.log('isResolving: ' + isResolvingUri)
if(!isResolvingUri && claim === undefined && uri) {
resolveUri(uri)
}
@@ -49,8 +49,7 @@ class ShowPage extends React.Component{
}
else if (claim.name.length && claim.name[0] === '@') {
- innerContent = "channel"
- // innerContent =
+ innerContent =
}
else if (claim) {
innerContent =
diff --git a/ui/js/reducers/claims.js b/ui/js/reducers/claims.js
index b8885d98a..6acf0f111 100644
--- a/ui/js/reducers/claims.js
+++ b/ui/js/reducers/claims.js
@@ -39,6 +39,24 @@ reducers[types.RESOLVE_URI_CANCELED] = function(state, action) {
})
}
+
+reducers[types.CLAIM_LIST_MINE_STARTED] = function(state, action) {
+ return Object.assign({}, state, {
+ isClaimListMinePending: true
+ })
+}
+
+reducers[types.CLAIM_LIST_MINE_COMPLETED] = function(state, action) {
+ const myClaims = Object.assign({}, state.myClaims)
+ action.data.claims.forEach((claim) => {
+ myClaims[claim.claim_id] = claim
+ })
+ return Object.assign({}, state, {
+ isClaimListMinePending: false,
+ myClaims: myClaims
+ })
+}
+
reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
const {
uri,
@@ -56,23 +74,6 @@ reducers[types.FETCH_CHANNEL_CLAIMS_COMPLETED] = function(state, action) {
})
}
-reducers[types.FETCH_MY_CLAIMS_COMPLETED] = function(state, action) {
- const {
- claims,
- } = action.data
- const newMine = Object.assign({}, state.mine)
- const newById = Object.assign({}, newMine.byId)
-
- claims.forEach(claim => {
- newById[claim.claim_id] = claim
- })
- newMine.byId = newById
-
- return Object.assign({}, state, {
- mine: newMine,
- })
-}
-
export default function reducer(state = defaultState, action) {
const handler = reducers[action.type];
if (handler) return handler(state, action);
diff --git a/ui/js/reducers/file_info.js b/ui/js/reducers/file_info.js
index affd4103d..811c829ef 100644
--- a/ui/js/reducers/file_info.js
+++ b/ui/js/reducers/file_info.js
@@ -64,22 +64,19 @@ reducers[types.DOWNLOADING_STARTED] = function(state, action) {
outpoint,
fileInfo,
} = action.data
- const newFileInfos = Object.assign({}, state.fileInfos)
- const newDownloading = Object.assign({}, state.downloading)
- const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
- const newLoading = Object.assign({}, state.loading)
- const newLoadingByUri = Object.assign({}, newLoading)
- newDownloadingByUri[uri] = true
- newDownloading.byUri = newDownloadingByUri
+ const newFileInfos = Object.assign({}, state.fileInfos)
+ const newDownloading = Object.assign({}, state.urisDownloading)
+ const newLoading = Object.assign({}, state.urisLoading)
+
+ newDownloading[uri] = true
newFileInfos[outpoint] = fileInfo
- delete newLoadingByUri[uri]
- newLoading.byUri = newLoadingByUri
+ delete newLoading[uri]
return Object.assign({}, state, {
- downloading: newDownloading,
+ urisDownloading: newDownloading,
+ urisLoading: newLoading,
fileInfos: newFileInfos,
- loading: newLoading,
})
}
@@ -89,15 +86,16 @@ reducers[types.DOWNLOADING_PROGRESSED] = function(state, action) {
outpoint,
fileInfo,
} = action.data
+
const newFileInfos = Object.assign({}, state.fileInfos)
- const newDownloading = Object.assign({}, state.downloading)
+ const newDownloading = Object.assign({}, state.urisDownloading)
newFileInfos[outpoint] = fileInfo
newDownloading[uri] = true
return Object.assign({}, state, {
- fileInfos: newByUri,
- downloading: newDownloading
+ fileInfos: newFileInfos,
+ urisDownloading: newDownloading
})
}
@@ -107,49 +105,29 @@ reducers[types.DOWNLOADING_COMPLETED] = function(state, action) {
outpoint,
fileInfo,
} = action.data
+
const newFileInfos = Object.assign({}, state.fileInfos)
- const newDownloading = Object.assign({}, state.downloading)
- const newDownloadingByUri = Object.assign({}, newDownloading.byUri)
+ const newDownloading = Object.assign({}, state.urisDownloading)
newFileInfos[outpoint] = fileInfo
- delete newDownloadingByUri[uri]
- newDownloading.byUri = newDownloadingByUri
+ delete newDownloading[uri]
return Object.assign({}, state, {
fileInfos: newFileInfos,
- downloading: newDownloading,
+ urisDownloading: newDownloading,
})
}
-reducers[types.DELETE_FILE_STARTED] = function(state, action) {
+reducers[types.FILE_DELETE] = function(state, action) {
const {
- outpoint
+ outpoint,
} = action.data
- const newDeleting = Object.assign({}, state.deleting)
- const newByUri = Object.assign({}, newDeleting.byUri)
- newFileInfos[outpoint] = true
- newDeleting.byUri = newFileInfos
-
- return Object.assign({}, state, {
- deleting: newDeleting,
- })
-}
-
-reducers[types.DELETE_FILE_COMPLETED] = function(state, action) {
- const {
- uri,
- } = action.data
- const newDeleting = Object.assign({}, state.deleting)
- const newDeletingByUri = Object.assign({}, newDeleting.byUri)
const newFileInfos = Object.assign({}, state.fileInfos)
- delete newDeletingByUri[uri]
- newDeleting.byUri = newDeletingByUri
delete newFileInfos[outpoint]
return Object.assign({}, state, {
- deleting: newDeleting,
fileInfos: newFileInfos,
})
}
@@ -158,14 +136,13 @@ reducers[types.LOADING_VIDEO_STARTED] = function(state, action) {
const {
uri,
} = action.data
- const newLoading = Object.assign({}, state.loading)
- const newFileInfos = Object.assign({}, newLoading.byUri)
- newFileInfos[outpoint] = true
- newLoading.byUri = newFileInfos
+ const newLoading = Object.assign({}, state.urisLoading)
+
+ newLoading[uri] = true
return Object.assign({}, state, {
- loading: newLoading,
+ urisLoading: newLoading,
})
}
@@ -173,59 +150,16 @@ reducers[types.LOADING_VIDEO_FAILED] = function(state, action) {
const {
uri,
} = action.data
- const newLoading = Object.assign({}, state.loading)
- const newFileInfos = Object.assign({}, newLoading.byUri)
- delete newFileInfos[outpoint]
- newLoading.byUri = newFileInfos
+ const newLoading = Object.assign({}, state.urisLoading)
+
+ delete newLoading[uri]
return Object.assign({}, state, {
- loading: newLoading,
+ urisLoading: newLoading,
})
}
-reducers[types.FETCH_DOWNLOADED_CONTENT_STARTED] = function(state, action) {
- return Object.assign({}, state, {
- fetchingDownloadedContent: true,
- })
-}
-
-reducers[types.FETCH_DOWNLOADED_CONTENT_COMPLETED] = function(state, action) {
- const newFileInfos = Object.assign({}, state.fileInfos)
-
- action.data.fileInfos.forEach(fileInfo => {
- newFileInfos[fileInfo.outpoint] = fileInfo
- })
-
- return Object.assign({}, state, {
- fileInfos: newFileInfos,
- 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 newFileInfos = Object.assign({}, state.fileInfos)
-
- fileInfos.forEach(fileInfo => {
- newFileInfos[fileInfo.outpoint] = fileInfo
- })
-
- return Object.assign({}, state, {
- fileInfos: newFileInfos,
- fetchingPublishedContent: false
- })
-}
-
-
export default function reducer(state = defaultState, action) {
const handler = reducers[action.type];
diff --git a/ui/js/selectors/claims.js b/ui/js/selectors/claims.js
index 9b7612859..9a76b872e 100644
--- a/ui/js/selectors/claims.js
+++ b/ui/js/selectors/claims.js
@@ -15,17 +15,6 @@ export const selectAllClaimsByChannel = createSelector(
(state) => state.claimsByChannel || {}
)
-export const selectClaimsForChannel = (state, props) => {
- return selectAllClaimsByChannel(state)[props.uri]
-}
-
-export const makeSelectClaimsForChannel = () => {
- return createSelector(
- selectClaimsForChannel,
- (claim) => claim
- )
-}
-
const selectClaimForUri = (state, props) => {
const uri = lbryuri.normalize(props.uri)
return selectClaimsByUri(state)[uri]
@@ -38,6 +27,17 @@ export const makeSelectClaimForUri = () => {
)
}
+export const selectClaimsInChannelForUri = (state, props) => {
+ return selectAllClaimsByChannel(state)[props.uri]
+}
+
+export const makeSelectClaimsInChannelForUri = () => {
+ return createSelector(
+ selectClaimsInChannelForUri,
+ (claims) => claims
+ )
+}
+
const selectMetadataForUri = (state, props) => {
const claim = selectClaimForUri(state, props)
const metadata = claim && claim.value && claim.value.stream && claim.value.stream.metadata
@@ -73,26 +73,25 @@ export const makeSelectContentTypeForUri = () => {
)
}
-export const selectMyClaims = createSelector(
+export const selectClaimListMineIsPending = createSelector(
_selectState,
- (state) => state.mine || {}
+ (state) => state.isClaimListMinePending
)
-export const selectMyClaimsById = createSelector(
- selectMyClaims,
- (mine) => mine.byId || {}
+export const selectMyClaims = createSelector(
+ _selectState,
+ (state) => state.myClaims || {}
)
export const selectMyClaimsOutpoints = createSelector(
- selectMyClaimsById,
- (byId) => {
- const outpoints = []
- Object.keys(byId).forEach(key => {
- const claim = byId[key]
- const outpoint = `${claim.txid}:${claim.nout}`
- outpoints.push(outpoint)
- })
+ selectMyClaims,
+ (claims) => {
+ if (!claims) {
+ return []
+ }
- return outpoints
+ return Object.values(claims).map((claim) => {
+ return `${claim.txid}:${claim.nout}`
+ })
}
)
diff --git a/ui/js/selectors/file_info.js b/ui/js/selectors/file_info.js
index c9104bbc2..cf7895d56 100644
--- a/ui/js/selectors/file_info.js
+++ b/ui/js/selectors/file_info.js
@@ -1,69 +1,38 @@
+import lbry from 'lbry'
import {
createSelector,
} from 'reselect'
import {
selectClaimsByUri,
+ selectClaimListMineIsPending,
selectMyClaimsOutpoints,
} from 'selectors/claims'
export const _selectState = state => state.fileInfo || {}
-export const selectIsFileListPending = createSelector(
- _selectState,
- (state) => state.isFileListPending
-)
-
export const selectAllFileInfos = createSelector(
_selectState,
(state) => state.fileInfos || {}
)
-export const selectDownloading = createSelector(
+export const selectFileListIsPending = createSelector(
_selectState,
- (state) => state.downloading || {}
+ (state) => state.isFileListPending
)
-export const selectDownloadingByUri = createSelector(
- selectDownloading,
- (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 selectFileListDownloadedOrPublishedIsPending = createSelector(
+ selectFileListIsPending,
+ selectClaimListMineIsPending,
+ (isFileListPending, isClaimListMinePending) => isFileListPending || isClaimListMinePending
)
export const selectFileInfoForUri = (state, props) => {
const claims = selectClaimsByUri(state),
claim = claims[props.uri],
+ fileInfos = selectAllFileInfos(state),
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
+ return outpoint && fileInfos ? fileInfos[outpoint] : undefined
}
export const makeSelectFileInfoForUri = () => {
@@ -73,8 +42,13 @@ export const makeSelectFileInfoForUri = () => {
)
}
+export const selectUrisDownloading = createSelector(
+ _selectState,
+ (state) => state.urisDownloading || {}
+)
+
const selectDownloadingForUri = (state, props) => {
- const byUri = selectDownloadingByUri(state)
+ const byUri = selectUrisDownloading(state)
return byUri[props.uri]
}
@@ -85,18 +59,13 @@ export const makeSelectDownloadingForUri = () => {
)
}
-export const selectLoading = createSelector(
+export const selectUrisLoading = createSelector(
_selectState,
- (state) => state.loading || {}
-)
-
-export const selectLoadingByUri = createSelector(
- selectLoading,
- (loading) => loading.byUri || {}
+ (state) => state.urisLoading || {}
)
const selectLoadingForUri = (state, props) => {
- const byUri = selectLoadingByUri(state)
+ const byUri = selectUrisLoading(state)
return byUri[props.uri]
}
@@ -107,13 +76,13 @@ export const makeSelectLoadingForUri = () => {
)
}
-export const selectDownloadedFileInfo = createSelector(
+export const selectFileInfosDownloaded = createSelector(
selectAllFileInfos,
- (fileInfos) => {
+ selectMyClaimsOutpoints,
+ (fileInfos, myClaimOutpoints) => {
const fileInfoList = []
- Object.keys(fileInfos).forEach(outpoint => {
- const fileInfo = fileInfos[outpoint]
- if (fileInfo.completed || fileInfo.written_bytes) {
+ Object.values(fileInfos).forEach(fileInfo => {
+ if (fileInfo && myClaimOutpoints.indexOf(fileInfo.outpoint) === -1 && (fileInfo.completed || fileInfo.written_bytes)) {
fileInfoList.push(fileInfo)
}
})
@@ -121,20 +90,24 @@ export const selectDownloadedFileInfo = createSelector(
}
)
-export const selectPublishedFileInfo = createSelector(
- selectAllFileInfos,
- selectMyClaimsOutpoints,
- (byUri, outpoints) => {
- const fileInfos = []
- outpoints.forEach(outpoint => {
- Object.keys(byUri).forEach(key => {
- const fileInfo = byUri[key]
- if (fileInfo.outpoint == outpoint) {
- fileInfos.push(fileInfo)
- }
- })
- })
-
- return fileInfos
+export const selectFileInfosPendingPublish = createSelector(
+ _selectState,
+ (state) => {
+ return lbry.getPendingPublishes()
+ }
+)
+
+export const selectFileInfosPublished = createSelector(
+ selectAllFileInfos,
+ selectFileInfosPendingPublish,
+ selectMyClaimsOutpoints,
+ (allFileInfos, pendingFileInfos, outpoints) => {
+ const fileInfos = []
+ outpoints.forEach(outpoint => {
+ if (allFileInfos[outpoint]) {
+ fileInfos.push(allFileInfos[outpoint])
+ }
+ })
+ return [...fileInfos, ...pendingFileInfos]
}
)