pausing during partial refactor

This commit is contained in:
Jeremy Kauffman 2017-09-07 17:18:33 -04:00
parent ff12ff3d36
commit bdf84b3dbd
12 changed files with 108 additions and 62 deletions

View file

@ -299,7 +299,7 @@ export function doLoadVideo(uri) {
data: { uri }, data: { uri },
}); });
dispatch(doOpenModal("timedOut")); dispatch(doOpenModal(modals.FILE_TIMEOUT));
} else { } else {
dispatch(doDownloadFile(uri, streamInfo)); dispatch(doDownloadFile(uri, streamInfo));
} }

View file

@ -1,6 +1,6 @@
import React from "react"; import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { selectPlatform, selectCurrentModal } from "selectors/app"; import { selectPlatform } from "selectors/app";
import { import {
makeSelectFileInfoForUri, makeSelectFileInfoForUri,
makeSelectDownloadingForUri, makeSelectDownloadingForUri,
@ -8,13 +8,10 @@ import {
} from "selectors/file_info"; } from "selectors/file_info";
import { makeSelectIsAvailableForUri } from "selectors/availability"; import { makeSelectIsAvailableForUri } from "selectors/availability";
import { makeSelectCostInfoForUri } from "selectors/cost_info"; import { makeSelectCostInfoForUri } from "selectors/cost_info";
import { doCloseModal, doOpenModal } from "actions/app"; import { doOpenModal } from "actions/app";
import { doFetchAvailability } from "actions/availability"; import { doFetchAvailability } from "actions/availability";
import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info"; import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info";
import { import { makeSelectClaimForUriIsMine } from "selectors/claims";
makeSelectClaimForUri,
makeSelectClaimForUriIsMine,
} from "selectors/claims";
import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content"; import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content";
import { doNavigate } from "actions/navigation"; import { doNavigate } from "actions/navigation";
import FileActions from "./view"; import FileActions from "./view";
@ -26,19 +23,16 @@ const makeSelect = () => {
const selectCostInfoForUri = makeSelectCostInfoForUri(); const selectCostInfoForUri = makeSelectCostInfoForUri();
const selectLoadingForUri = makeSelectLoadingForUri(); const selectLoadingForUri = makeSelectLoadingForUri();
const selectClaimForUriIsMine = makeSelectClaimForUriIsMine(); const selectClaimForUriIsMine = makeSelectClaimForUriIsMine();
const selectClaimForUri = makeSelectClaimForUri();
const select = (state, props) => ({ const select = (state, props) => ({
fileInfo: selectFileInfoForUri(state, props), fileInfo: selectFileInfoForUri(state, props),
/*availability check is disabled due to poor performance, TBD if it dies forever or requires daemon fix*/ /*availability check is disabled due to poor performance, TBD if it dies forever or requires daemon fix*/
isAvailable: true, //selectIsAvailableForUri(state, props), isAvailable: true, //selectIsAvailableForUri(state, props),
platform: selectPlatform(state), platform: selectPlatform(state),
modal: selectCurrentModal(state),
downloading: selectDownloadingForUri(state, props), downloading: selectDownloadingForUri(state, props),
costInfo: selectCostInfoForUri(state, props), costInfo: selectCostInfoForUri(state, props),
loading: selectLoadingForUri(state, props), loading: selectLoadingForUri(state, props),
claimIsMine: selectClaimForUriIsMine(state, props), claimIsMine: selectClaimForUriIsMine(state, props),
claimInfo: selectClaimForUri(state, props),
}); });
return select; return select;
@ -46,7 +40,6 @@ const makeSelect = () => {
const perform = dispatch => ({ const perform = dispatch => ({
checkAvailability: uri => dispatch(doFetchAvailability(uri)), checkAvailability: uri => dispatch(doFetchAvailability(uri)),
closeModal: () => dispatch(doCloseModal()),
openInFolder: fileInfo => dispatch(doOpenFileInFolder(fileInfo)), openInFolder: fileInfo => dispatch(doOpenFileInFolder(fileInfo)),
openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)), openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)),
openModal: modal => dispatch(doOpenModal(modal)), openModal: modal => dispatch(doOpenModal(modal)),

View file

@ -1,11 +1,8 @@
import React from "react"; import React from "react";
import { Icon, BusyMessage } from "component/common"; import { Icon, BusyMessage } from "component/common";
import FilePrice from "component/filePrice";
import { Modal } from "modal/modal";
import Link from "component/link"; 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";
import ModalRemoveFile from "modal/modalRemoveFile";
import * as modals from "constants/modal_types"; import * as modals from "constants/modal_types";
class FileActions extends React.PureComponent { class FileActions extends React.PureComponent {
@ -70,15 +67,11 @@ class FileActions extends React.PureComponent {
uri, uri,
openInFolder, openInFolder,
openInShell, openInShell,
modal,
openModal, openModal,
closeModal,
startDownload, startDownload,
costInfo, costInfo,
loading, loading,
claimIsMine, claimIsMine,
claimInfo,
navigate,
editClaim, editClaim,
} = this.props; } = this.props;
@ -204,33 +197,7 @@ class FileActions extends React.PureComponent {
</DropDownMenu> </DropDownMenu>
</div> </div>
: ""} : ""}
<Modal
type="confirm"
isOpen={modal == "affirmPurchase"}
contentLabel={__("Confirm Purchase")}
onConfirmed={this.onAffirmPurchase.bind(this)}
onAborted={closeModal}
>
{__("This will purchase")} <strong>{title}</strong> {__("for")}{" "}
<strong>
<FilePrice uri={uri} showFullPrice={true} look="plain" />
</strong>{" "}
{__("credits")}.
</Modal>
<Modal
isOpen={modal == "timedOut"}
contentLabel={__("Download failed")}
onConfirmed={closeModal}
>
{__("LBRY was unable to download the stream")}{" "}{" "}
<strong>{title}</strong>.
</Modal>
{modal == modals.CONFIRM_FILE_REMOVE &&
<ModalRemoveFile
uri={uri}
outpoint={fileInfo.outpoint}
title={title}
/>}
</section> </section>
); );
} }

View file

@ -87,13 +87,6 @@ class VideoPlayButton extends React.PureComponent {
</strong>{" "} </strong>{" "}
{__("credits")}. {__("credits")}.
</Modal> </Modal>
<Modal
isOpen={modal == "timedOut"}
onConfirmed={closeModal}
contentLabel={__("Timed Out")}
>
{__("Sorry, your download timed out :(")}
</Modal>
</div> </div>
); );
} }

View file

@ -1,5 +1,6 @@
export const CONFIRM_FILE_REMOVE = "confirmFileRemove"; export const CONFIRM_FILE_REMOVE = "confirmFileRemove";
export const INCOMPATIBLE_DAEMON = "incompatibleDaemon"; export const INCOMPATIBLE_DAEMON = "incompatibleDaemon";
export const FILE_TIMEOUT = "file_timeout";
export const DOWNLOADING = "downloading"; export const DOWNLOADING = "downloading";
export const ERROR = "error"; export const ERROR = "error";
export const INSUFFICIENT_CREDITS = "insufficient_credits"; export const INSUFFICIENT_CREDITS = "insufficient_credits";
@ -10,4 +11,5 @@ export const AUTHENTICATION_FAILURE = "auth_failure";
export const TRANSACTION_FAILED = "transaction_failed"; export const TRANSACTION_FAILED = "transaction_failed";
export const INSUFFICIENT_BALANCE = "insufficient_balance"; export const INSUFFICIENT_BALANCE = "insufficient_balance";
export const REWARD_APPROVAL_REQUIRED = "reward_approval_required"; export const REWARD_APPROVAL_REQUIRED = "reward_approval_required";
export const AFFIRM_PURCHASE = "affirm_purchase";
export const CREDIT_INTRO = "credit_intro"; export const CREDIT_INTRO = "credit_intro";

View file

@ -0,0 +1,15 @@
import React from "react";
import { connect } from "react-redux";
import { doCloseModal } from "actions/app";
import { makeSelectMetadataForUri } from "selectors/claims";
import ModalAffirmPurchase from "./view";
const select = state => ({
metadata: makeSelectMetadataForUri()(state),
});
const perform = dispatch => ({
closeModal: () => dispatch(doCloseModal()),
});
export default connect(select, perform)(ModalAffirmPurchase);

View file

@ -0,0 +1,27 @@
import React from "react";
import FilePrice from "component/filePrice";
import { Modal } from "modal/modal";
class ModalAffirmPurchase extends React.PureComponent {
render() {
const { metadata: { title } } = this.props;
return (
<Modal
type="confirm"
isOpen={modal == "affirmPurchase"}
contentLabel={__("Confirm Purchase")}
onConfirmed={this.onAffirmPurchase.bind(this)}
onAborted={closeModal}
>
{__("This will purchase")} <strong>{title}</strong> {__("for")}{" "}
<strong>
<FilePrice uri={uri} showFullPrice={true} look="plain" />
</strong>{" "}
{__("credits")}.
</Modal>
);
}
}
export default ModalAffirmPurchase;

View file

@ -0,0 +1,15 @@
import React from "react";
import { connect } from "react-redux";
import { doCloseModal } from "actions/app";
import { makeSelectMetadataForUri } from "selectors/claims";
import ModalFileTimeout from "./view";
const select = state => ({
metadata: makeSelectMetadataForUri()(state),
});
const perform = dispatch => ({
closeModal: () => dispatch(doCloseModal()),
});
export default connect(select, perform)(ModalFileTimeout);

View file

@ -0,0 +1,21 @@
import React from "react";
import { Modal } from "modal/modal";
class ModalFileTimeout extends React.PureComponent {
render() {
const { metadata: { title } } = this.props;
return (
<Modal
isOpen={true}
contentLabel={__("Download failed")}
onConfirmed={closeModal}
>
{__("LBRY was unable to download the stream")}{" "}
<strong>{title}</strong>.
</Modal>
);
}
}
export default ModalFileTimeout;

View file

@ -5,16 +5,14 @@ import { doDeleteFileAndGoBack } from "actions/file_info";
import { makeSelectClaimForUriIsMine } from "selectors/claims"; import { makeSelectClaimForUriIsMine } from "selectors/claims";
import ModalRemoveFile from "./view"; import ModalRemoveFile from "./view";
import { makeSelectFileInfoForUri } from "../../selectors/file_info";
const makeSelect = () => { const select = (state, props) => ({
const selectClaimForUriIsMine = makeSelectClaimForUriIsMine(); claimIsMine: makeSelectClaimForUriIsMine()(state, props),
uri: makeSelectCurrentParam("uri")(state, props),
const select = (state, props) => ({ metadata: makeSelectMetadataForUri()(state, props),
claimIsMine: selectClaimForUriIsMine(state, props), outpoint: makeSelectFileInfoForUri()(state, props),
}); });
return select;
};
const perform = dispatch => ({ const perform = dispatch => ({
closeModal: () => dispatch(doCloseModal()), closeModal: () => dispatch(doCloseModal()),
@ -23,4 +21,4 @@ const perform = dispatch => ({
}, },
}); });
export default connect(makeSelect, perform)(ModalRemoveFile); export default connect(select, perform)(ModalRemoveFile);

View file

@ -10,6 +10,8 @@ import ModalRewardApprovalRequired from "modal/modalRewardApprovalRequired";
import ModalCreditIntro from "modal/modalCreditIntro"; import ModalCreditIntro from "modal/modalCreditIntro";
import ModalTransactionFailed from "modal/modalTransactionFailed"; import ModalTransactionFailed from "modal/modalTransactionFailed";
import ModalInsufficientBalance from "modal/modalInsufficientBalance"; import ModalInsufficientBalance from "modal/modalInsufficientBalance";
import ModalFileTimeout from "modal/modalFileTimeout";
import ModalAffirmPurchase from "modal/modalAffirmPurchase";
import * as modals from "constants/modal_types"; import * as modals from "constants/modal_types";
class ModalRouter extends React.PureComponent { class ModalRouter extends React.PureComponent {
@ -107,6 +109,8 @@ class ModalRouter extends React.PureComponent {
return <ModalDownloading />; return <ModalDownloading />;
case modals.ERROR: case modals.ERROR:
return <ModalError />; return <ModalError />;
case modals.FILE_TIMEOUT:
return <ModalFileTimeout />;
case modals.INSUFFICIENT_CREDITS: case modals.INSUFFICIENT_CREDITS:
return <ModalInsufficientCredits />; return <ModalInsufficientCredits />;
case modals.WELCOME: case modals.WELCOME:
@ -123,6 +127,10 @@ class ModalRouter extends React.PureComponent {
return <ModalInsufficientBalance />; return <ModalInsufficientBalance />;
case modals.REWARD_APPROVAL_REQUIRED: case modals.REWARD_APPROVAL_REQUIRED:
return <ModalRewardApprovalRequired />; return <ModalRewardApprovalRequired />;
case modals.CONFIRM_FILE_REMOVE:
return <ModalRemoveFile />;
case modals.AFFIRM_PURCHASE:
return <ModalAffirmPurchase />;
default: default:
return null; return null;
} }

View file

@ -21,6 +21,13 @@ export const selectCurrentParams = createSelector(selectCurrentPath, path => {
return parseQueryParams(path.split("?")[1]); return parseQueryParams(path.split("?")[1]);
}); });
export const makeSelectCurrentParam = param => {
return createSelector(
selectCurrentParams,
params => (params ? params[param] : undefined)
);
};
export const selectHeaderLinks = createSelector(selectCurrentPage, page => { export const selectHeaderLinks = createSelector(selectCurrentPage, page => {
// This contains intentional fall throughs // This contains intentional fall throughs
switch (page) { switch (page) {