fix availability issue and restore open in folder

This commit is contained in:
Jeremy Kauffman 2017-09-20 08:47:08 -04:00
parent 47aec4efcf
commit 2746627fb1
7 changed files with 43 additions and 10 deletions

View file

@ -4,6 +4,11 @@ import { selectFetchingAvailability } from "selectors/availability";
export function doFetchAvailability(uri) {
return function(dispatch, getState) {
/*
this is disabled atm - Jeremy
*/
return;
const state = getState();
const alreadyFetching = !!selectFetchingAvailability(state)[uri];

View file

@ -71,18 +71,18 @@ export function doFileList() {
};
}
export function doOpenFileInShell(fileInfo) {
export function doOpenFileInShell(path) {
return function(dispatch, getState) {
const success = shell.openItem(fileInfo.download_path);
const success = shell.openItem(path);
if (!success) {
dispatch(doOpenFileInFolder(fileInfo));
dispatch(doOpenFileInFolder(path));
}
};
}
export function doOpenFileInFolder(fileInfo) {
export function doOpenFileInFolder(path) {
return function(dispatch, getState) {
shell.showItemInFolder(fileInfo.download_path);
shell.showItemInFolder(path);
};
}

View file

@ -6,11 +6,18 @@ import {
makeSelectMetadataForUri,
} from "selectors/claims";
import FileDetails from "./view";
import { doOpenFileInFolder } from "actions/file_info";
import { makeSelectFileInfoForUri } from "selectors/file_info";
const select = (state, props) => ({
claim: makeSelectClaimForUri(props.uri)(state),
contentType: makeSelectContentTypeForUri(props.uri)(state),
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
metadata: makeSelectMetadataForUri(props.uri)(state),
});
export default connect(select, null)(FileDetails);
const perform = dispatch => ({
openFolder: path => dispatch(doOpenFileInFolder(path)),
});
export default connect(select, perform)(FileDetails);

View file

@ -5,9 +5,18 @@ import FileActions from "component/fileActions";
import Link from "component/link";
import DateTime from "component/dateTime";
const path = require("path");
class FileDetails extends React.PureComponent {
render() {
const { claim, contentType, metadata, uri } = this.props;
const {
claim,
contentType,
fileInfo,
metadata,
openFolder,
uri,
} = this.props;
if (!claim || !metadata) {
return (
@ -20,6 +29,9 @@ class FileDetails extends React.PureComponent {
const { description, language, license } = metadata;
const { height } = claim;
const mediaType = lbry.getMediaType(contentType);
const directory = fileInfo && fileInfo.download_path
? path.dirname(fileInfo.download_path)
: null;
return (
<div>
@ -47,6 +59,15 @@ class FileDetails extends React.PureComponent {
<tr>
<td>{__("License")}</td><td>{license}</td>
</tr>
{directory &&
<tr>
<td>{__("Downloaded to")}</td>
<td>
<Link onClick={() => openFolder(directory)}>
{directory}
</Link>
</td>
</tr>}
</tbody>
</table>
<p>

View file

@ -10,7 +10,6 @@ import { doFetchAvailability } from "actions/availability";
import { doOpenFileInShell } from "actions/file_info";
import { doPurchaseUri, doStartDownload } from "actions/content";
import FileDownloadLink from "./view";
import * as modals from "constants/modal_types";
const select = (state, props) => ({
fileInfo: makeSelectFileInfoForUri(props.uri)(state),
@ -22,7 +21,7 @@ const select = (state, props) => ({
const perform = dispatch => ({
checkAvailability: uri => dispatch(doFetchAvailability(uri)),
openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)),
openInShell: path => dispatch(doOpenFileInShell(path)),
purchaseUri: uri => dispatch(doPurchaseUri(uri)),
restartDownload: (uri, outpoint) => dispatch(doStartDownload(uri, outpoint)),
});

View file

@ -92,7 +92,7 @@ class FileDownloadLink extends React.PureComponent {
label={__("Open")}
button="text"
icon="icon-external-link-square"
onClick={() => openInShell(fileInfo)}
onClick={() => openInShell(fileInfo.download_path)}
/>
);
}

View file

@ -36,6 +36,7 @@ class ShowPage extends React.PureComponent {
message={__("Loading magic decentralized data...")}
/>}
{claim === null &&
!isResolvingUri &&
<span className="empty">
{__("There's nothing at this location.")}
</span>}