mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-30 17:01:25 +00:00
Merge pull request #241 from lbryio/refresh-claim-list-mine
Always refresh claims/file info on downloaded/published pages
This commit is contained in:
commit
be198e0cf4
6 changed files with 20 additions and 36 deletions
|
@ -98,16 +98,9 @@ export function doDeleteFile(outpoint, deleteFromComputer) {
|
||||||
|
|
||||||
export function doFetchFileInfosAndPublishedClaims() {
|
export function doFetchFileInfosAndPublishedClaims() {
|
||||||
return function(dispatch, getState) {
|
return function(dispatch, getState) {
|
||||||
const state = getState(),
|
const state = getState();
|
||||||
isClaimListMinePending = selectClaimListMineIsPending(state),
|
|
||||||
isFileInfoListPending = selectFileListIsPending(state);
|
|
||||||
|
|
||||||
if (isClaimListMinePending === undefined) {
|
dispatch(doFetchClaimListMine());
|
||||||
dispatch(doFetchClaimListMine());
|
dispatch(doFileList());
|
||||||
}
|
|
||||||
|
|
||||||
if (isFileInfoListPending === undefined) {
|
|
||||||
dispatch(doFileList());
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ class FileList extends React.PureComponent {
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<section className="file-list__header">
|
<section className="file-list__header">
|
||||||
{fetching && <span className="busy-indicator" />}
|
{fetching && <BusyMessage />}
|
||||||
<span className="sort-section">
|
<span className="sort-section">
|
||||||
{__("Sort by")} {" "}
|
{__("Sort by")} {" "}
|
||||||
<FormField type="select" onChange={this.handleSortChanged.bind(this)}>
|
<FormField type="select" onChange={this.handleSortChanged.bind(this)}>
|
||||||
|
|
|
@ -19,14 +19,14 @@ class FileTile extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.resolve(this.props);
|
const { isResolvingUri, claim, uri, resolveUri } = this.props;
|
||||||
|
|
||||||
|
if (!isResolvingUri && !claim && uri) resolveUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
this.resolve(nextProps);
|
const { isResolvingUri, claim, uri, resolveUri } = this.props;
|
||||||
}
|
|
||||||
|
|
||||||
resolve({ isResolvingUri, claim, uri, resolveUri }) {
|
|
||||||
if (!isResolvingUri && claim === undefined && uri) resolveUri(uri);
|
if (!isResolvingUri && claim === undefined && uri) resolveUri(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -417,7 +417,7 @@ lbry.file_list = function(params = {}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apiCall(
|
apiCall(
|
||||||
"file_list",
|
"file_list",
|
||||||
params,
|
params,
|
||||||
|
@ -458,30 +458,21 @@ lbry.claim_list_mine = function(params = {}) {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const claimCacheKey = "resolve_claim_cache";
|
|
||||||
lbry._claimCache = getSession(claimCacheKey, {});
|
|
||||||
lbry._resolveXhrs = {};
|
lbry._resolveXhrs = {};
|
||||||
lbry.resolve = function(params = {}) {
|
lbry.resolve = function(params = {}) {
|
||||||
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");
|
||||||
}
|
}
|
||||||
if (params.uri && lbry._claimCache[params.uri] !== undefined) {
|
lbry._resolveXhrs[params.uri] = apiCall(
|
||||||
resolve(lbry._claimCache[params.uri]);
|
"resolve",
|
||||||
} else {
|
params,
|
||||||
lbry._resolveXhrs[params.uri] = apiCall(
|
function(data) {
|
||||||
"resolve",
|
resolve(data && data[params.uri] ? data[params.uri] : {});
|
||||||
params,
|
},
|
||||||
data => {
|
reject
|
||||||
if (data !== undefined) {
|
);
|
||||||
lbry._claimCache[params.uri] = data;
|
|
||||||
}
|
|
||||||
setSession(claimCacheKey, lbry._claimCache);
|
|
||||||
resolve(data && data[params.uri] ? data[params.uri] : {});
|
|
||||||
},
|
|
||||||
reject
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import SubHeader from "component/subHeader";
|
||||||
|
|
||||||
class FileListDownloaded extends React.PureComponent {
|
class FileListDownloaded extends React.PureComponent {
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.props.fetchFileInfosDownloaded();
|
if (!this.props.isPending) this.props.fetchFileInfosDownloaded();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import SubHeader from "component/subHeader";
|
||||||
|
|
||||||
class FileListPublished extends React.PureComponent {
|
class FileListPublished extends React.PureComponent {
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.props.fetchFileListPublished();
|
if (!this.props.isPending) this.props.fetchFileListPublished();
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue