From bdf84b3dbd22ce717d766b4458a6628aeef83898 Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Thu, 7 Sep 2017 17:18:33 -0400 Subject: [PATCH] pausing during partial refactor --- ui/js/actions/content.js | 2 +- ui/js/component/fileActions/index.js | 13 ++----- ui/js/component/fileActions/view.jsx | 35 +------------------ .../component/video/internal/play-button.jsx | 7 ---- ui/js/constants/modal_types.js | 2 ++ ui/js/modal/modalAffirmPurchase/index.js | 15 ++++++++ ui/js/modal/modalAffirmPurchase/view.jsx | 27 ++++++++++++++ ui/js/modal/modalFileTimeout/index.js | 15 ++++++++ ui/js/modal/modalFileTimeout/view.jsx | 21 +++++++++++ ui/js/modal/modalRemoveFile/index.js | 18 +++++----- ui/js/modal/modalRouter/view.jsx | 8 +++++ ui/js/selectors/navigation.js | 7 ++++ 12 files changed, 108 insertions(+), 62 deletions(-) create mode 100644 ui/js/modal/modalAffirmPurchase/index.js create mode 100644 ui/js/modal/modalAffirmPurchase/view.jsx create mode 100644 ui/js/modal/modalFileTimeout/index.js create mode 100644 ui/js/modal/modalFileTimeout/view.jsx diff --git a/ui/js/actions/content.js b/ui/js/actions/content.js index 69c717e88..60961ad10 100644 --- a/ui/js/actions/content.js +++ b/ui/js/actions/content.js @@ -299,7 +299,7 @@ export function doLoadVideo(uri) { data: { uri }, }); - dispatch(doOpenModal("timedOut")); + dispatch(doOpenModal(modals.FILE_TIMEOUT)); } else { dispatch(doDownloadFile(uri, streamInfo)); } diff --git a/ui/js/component/fileActions/index.js b/ui/js/component/fileActions/index.js index 461e7a14a..0afa74839 100644 --- a/ui/js/component/fileActions/index.js +++ b/ui/js/component/fileActions/index.js @@ -1,6 +1,6 @@ import React from "react"; import { connect } from "react-redux"; -import { selectPlatform, selectCurrentModal } from "selectors/app"; +import { selectPlatform } from "selectors/app"; import { makeSelectFileInfoForUri, makeSelectDownloadingForUri, @@ -8,13 +8,10 @@ import { } from "selectors/file_info"; import { makeSelectIsAvailableForUri } from "selectors/availability"; import { makeSelectCostInfoForUri } from "selectors/cost_info"; -import { doCloseModal, doOpenModal } from "actions/app"; +import { doOpenModal } from "actions/app"; import { doFetchAvailability } from "actions/availability"; import { doOpenFileInShell, doOpenFileInFolder } from "actions/file_info"; -import { - makeSelectClaimForUri, - makeSelectClaimForUriIsMine, -} from "selectors/claims"; +import { makeSelectClaimForUriIsMine } from "selectors/claims"; import { doPurchaseUri, doLoadVideo, doStartDownload } from "actions/content"; import { doNavigate } from "actions/navigation"; import FileActions from "./view"; @@ -26,19 +23,16 @@ const makeSelect = () => { const selectCostInfoForUri = makeSelectCostInfoForUri(); const selectLoadingForUri = makeSelectLoadingForUri(); const selectClaimForUriIsMine = makeSelectClaimForUriIsMine(); - const selectClaimForUri = makeSelectClaimForUri(); const select = (state, props) => ({ fileInfo: selectFileInfoForUri(state, props), /*availability check is disabled due to poor performance, TBD if it dies forever or requires daemon fix*/ isAvailable: true, //selectIsAvailableForUri(state, props), platform: selectPlatform(state), - modal: selectCurrentModal(state), downloading: selectDownloadingForUri(state, props), costInfo: selectCostInfoForUri(state, props), loading: selectLoadingForUri(state, props), claimIsMine: selectClaimForUriIsMine(state, props), - claimInfo: selectClaimForUri(state, props), }); return select; @@ -46,7 +40,6 @@ const makeSelect = () => { const perform = dispatch => ({ checkAvailability: uri => dispatch(doFetchAvailability(uri)), - closeModal: () => dispatch(doCloseModal()), openInFolder: fileInfo => dispatch(doOpenFileInFolder(fileInfo)), openInShell: fileInfo => dispatch(doOpenFileInShell(fileInfo)), openModal: modal => dispatch(doOpenModal(modal)), diff --git a/ui/js/component/fileActions/view.jsx b/ui/js/component/fileActions/view.jsx index f7f8a3842..51ef4bd84 100644 --- a/ui/js/component/fileActions/view.jsx +++ b/ui/js/component/fileActions/view.jsx @@ -1,11 +1,8 @@ import React from "react"; import { Icon, BusyMessage } from "component/common"; -import FilePrice from "component/filePrice"; -import { Modal } from "modal/modal"; import Link from "component/link"; import { ToolTip } from "component/tooltip"; import { DropDownMenu, DropDownMenuItem } from "component/menu"; -import ModalRemoveFile from "modal/modalRemoveFile"; import * as modals from "constants/modal_types"; class FileActions extends React.PureComponent { @@ -70,15 +67,11 @@ class FileActions extends React.PureComponent { uri, openInFolder, openInShell, - modal, openModal, - closeModal, startDownload, costInfo, loading, claimIsMine, - claimInfo, - navigate, editClaim, } = this.props; @@ -204,33 +197,7 @@ class FileActions extends React.PureComponent { : ""} - - {__("This will purchase")} {title} {__("for")}{" "} - - - {" "} - {__("credits")}. - - - {__("LBRY was unable to download the stream")}{" "}{" "} - {title}. - - {modal == modals.CONFIRM_FILE_REMOVE && - } + ); } diff --git a/ui/js/component/video/internal/play-button.jsx b/ui/js/component/video/internal/play-button.jsx index 2ae39fe7c..17d2817db 100644 --- a/ui/js/component/video/internal/play-button.jsx +++ b/ui/js/component/video/internal/play-button.jsx @@ -87,13 +87,6 @@ class VideoPlayButton extends React.PureComponent { {" "} {__("credits")}. - - {__("Sorry, your download timed out :(")} - ); } diff --git a/ui/js/constants/modal_types.js b/ui/js/constants/modal_types.js index 09ddb8451..9e82be50a 100644 --- a/ui/js/constants/modal_types.js +++ b/ui/js/constants/modal_types.js @@ -1,5 +1,6 @@ export const CONFIRM_FILE_REMOVE = "confirmFileRemove"; export const INCOMPATIBLE_DAEMON = "incompatibleDaemon"; +export const FILE_TIMEOUT = "file_timeout"; export const DOWNLOADING = "downloading"; export const ERROR = "error"; export const INSUFFICIENT_CREDITS = "insufficient_credits"; @@ -10,4 +11,5 @@ export const AUTHENTICATION_FAILURE = "auth_failure"; export const TRANSACTION_FAILED = "transaction_failed"; export const INSUFFICIENT_BALANCE = "insufficient_balance"; export const REWARD_APPROVAL_REQUIRED = "reward_approval_required"; +export const AFFIRM_PURCHASE = "affirm_purchase"; export const CREDIT_INTRO = "credit_intro"; diff --git a/ui/js/modal/modalAffirmPurchase/index.js b/ui/js/modal/modalAffirmPurchase/index.js new file mode 100644 index 000000000..f76921431 --- /dev/null +++ b/ui/js/modal/modalAffirmPurchase/index.js @@ -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); diff --git a/ui/js/modal/modalAffirmPurchase/view.jsx b/ui/js/modal/modalAffirmPurchase/view.jsx new file mode 100644 index 000000000..3f886322e --- /dev/null +++ b/ui/js/modal/modalAffirmPurchase/view.jsx @@ -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 ( + + {__("This will purchase")} {title} {__("for")}{" "} + + + {" "} + {__("credits")}. + + ); + } +} + +export default ModalAffirmPurchase; diff --git a/ui/js/modal/modalFileTimeout/index.js b/ui/js/modal/modalFileTimeout/index.js new file mode 100644 index 000000000..44dd592e7 --- /dev/null +++ b/ui/js/modal/modalFileTimeout/index.js @@ -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); diff --git a/ui/js/modal/modalFileTimeout/view.jsx b/ui/js/modal/modalFileTimeout/view.jsx new file mode 100644 index 000000000..9a0916c66 --- /dev/null +++ b/ui/js/modal/modalFileTimeout/view.jsx @@ -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 ( + + {__("LBRY was unable to download the stream")}{" "} + {title}. + + ); + } +} + +export default ModalFileTimeout; diff --git a/ui/js/modal/modalRemoveFile/index.js b/ui/js/modal/modalRemoveFile/index.js index f64c1987e..c3ae80968 100644 --- a/ui/js/modal/modalRemoveFile/index.js +++ b/ui/js/modal/modalRemoveFile/index.js @@ -5,16 +5,14 @@ import { doDeleteFileAndGoBack } from "actions/file_info"; import { makeSelectClaimForUriIsMine } from "selectors/claims"; import ModalRemoveFile from "./view"; +import { makeSelectFileInfoForUri } from "../../selectors/file_info"; -const makeSelect = () => { - const selectClaimForUriIsMine = makeSelectClaimForUriIsMine(); - - const select = (state, props) => ({ - claimIsMine: selectClaimForUriIsMine(state, props), - }); - - return select; -}; +const select = (state, props) => ({ + claimIsMine: makeSelectClaimForUriIsMine()(state, props), + uri: makeSelectCurrentParam("uri")(state, props), + metadata: makeSelectMetadataForUri()(state, props), + outpoint: makeSelectFileInfoForUri()(state, props), +}); const perform = dispatch => ({ closeModal: () => dispatch(doCloseModal()), @@ -23,4 +21,4 @@ const perform = dispatch => ({ }, }); -export default connect(makeSelect, perform)(ModalRemoveFile); +export default connect(select, perform)(ModalRemoveFile); diff --git a/ui/js/modal/modalRouter/view.jsx b/ui/js/modal/modalRouter/view.jsx index 47ff2d80c..d74cddc44 100644 --- a/ui/js/modal/modalRouter/view.jsx +++ b/ui/js/modal/modalRouter/view.jsx @@ -10,6 +10,8 @@ import ModalRewardApprovalRequired from "modal/modalRewardApprovalRequired"; import ModalCreditIntro from "modal/modalCreditIntro"; import ModalTransactionFailed from "modal/modalTransactionFailed"; import ModalInsufficientBalance from "modal/modalInsufficientBalance"; +import ModalFileTimeout from "modal/modalFileTimeout"; +import ModalAffirmPurchase from "modal/modalAffirmPurchase"; import * as modals from "constants/modal_types"; class ModalRouter extends React.PureComponent { @@ -107,6 +109,8 @@ class ModalRouter extends React.PureComponent { return ; case modals.ERROR: return ; + case modals.FILE_TIMEOUT: + return ; case modals.INSUFFICIENT_CREDITS: return ; case modals.WELCOME: @@ -123,6 +127,10 @@ class ModalRouter extends React.PureComponent { return ; case modals.REWARD_APPROVAL_REQUIRED: return ; + case modals.CONFIRM_FILE_REMOVE: + return ; + case modals.AFFIRM_PURCHASE: + return ; default: return null; } diff --git a/ui/js/selectors/navigation.js b/ui/js/selectors/navigation.js index ca95e259f..08ae51774 100644 --- a/ui/js/selectors/navigation.js +++ b/ui/js/selectors/navigation.js @@ -21,6 +21,13 @@ export const selectCurrentParams = createSelector(selectCurrentPath, path => { return parseQueryParams(path.split("?")[1]); }); +export const makeSelectCurrentParam = param => { + return createSelector( + selectCurrentParams, + params => (params ? params[param] : undefined) + ); +}; + export const selectHeaderLinks = createSelector(selectCurrentPage, page => { // This contains intentional fall throughs switch (page) {