From 90c219ff38c7ff3844e4fbd9caaadd33e2eac981 Mon Sep 17 00:00:00 2001 From: Thomas Zarebczan Date: Thu, 15 Aug 2019 07:36:03 -0400 Subject: [PATCH 1/2] fix: more bugs We should still allow file removal if someone doesn't want to delete the file from their PC, but delete it from My Library No need to show connecting/status while claim is resolving Fix channel edit bug on vanity url --- package.json | 2 +- src/ui/component/channelEdit/index.js | 2 ++ src/ui/component/channelEdit/view.jsx | 7 +++---- src/ui/component/fileDownloadLink/index.js | 8 +------- src/ui/component/fileDownloadLink/view.jsx | 5 ++--- src/ui/modal/modalRemoveFile/view.jsx | 2 +- src/ui/redux/actions/file.js | 2 +- yarn.lock | 4 ++-- 8 files changed, 13 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 848d1114d..6c2d30bf0 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "jsmediatags": "^3.8.1", "json-loader": "^0.5.4", "lbry-format": "https://github.com/lbryio/lbry-format.git", - "lbry-redux": "lbryio/lbry-redux#027c517ec653f328eeed2cf509b1062b0f787f22", + "lbry-redux": "lbryio/lbry-redux#1af092ce2cb507d9a41711b864874c0bd76935ae", "lbryinc": "lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585", "lint-staged": "^7.0.2", "localforage": "^1.7.1", diff --git a/src/ui/component/channelEdit/index.js b/src/ui/component/channelEdit/index.js index 61742cd00..6f0617eea 100644 --- a/src/ui/component/channelEdit/index.js +++ b/src/ui/component/channelEdit/index.js @@ -7,6 +7,7 @@ import { makeSelectMetadataItemForUri, doUpdateChannel, makeSelectAmountForUri, + makeSelectClaimForUri, } from 'lbry-redux'; import ChannelPage from './view'; @@ -22,6 +23,7 @@ const select = (state, props) => ({ locations: makeSelectMetadataItemForUri(props.uri, 'locations')(state), languages: makeSelectMetadataItemForUri(props.uri, 'languages')(state), amount: makeSelectAmountForUri(props.uri)(state), + claim: makeSelectClaimForUri(props.uri)(state), }); const perform = dispatch => ({ diff --git a/src/ui/component/channelEdit/view.jsx b/src/ui/component/channelEdit/view.jsx index 00277d264..71603ff9e 100644 --- a/src/ui/component/channelEdit/view.jsx +++ b/src/ui/component/channelEdit/view.jsx @@ -1,13 +1,12 @@ // @flow import React, { useState } from 'react'; -import { parseURI } from 'lbry-redux'; import { Form, FormField } from 'component/common/form'; import Button from 'component/button'; import SelectAsset from 'component/selectAsset'; import TagSelect from 'component/tagsSelect'; type Props = { - uri: string, + claim: ChannelClaim, title: ?string, amount: string, cover: ?string, @@ -28,7 +27,7 @@ type Props = { function ChannelForm(props: Props) { const { - uri, + claim, title, cover, description, @@ -44,7 +43,7 @@ function ChannelForm(props: Props) { updateThumb, updateCover, } = props; - const { claimId } = parseURI(uri); + const { claim_id: claimId } = claim; // fill this in with sdk data const channelParams = { diff --git a/src/ui/component/fileDownloadLink/index.js b/src/ui/component/fileDownloadLink/index.js index 2481ef9e8..88fcffcec 100644 --- a/src/ui/component/fileDownloadLink/index.js +++ b/src/ui/component/fileDownloadLink/index.js @@ -1,10 +1,5 @@ import { connect } from 'react-redux'; -import { - makeSelectFileInfoForUri, - makeSelectDownloadingForUri, - makeSelectLoadingForUri, - makeSelectClaimIsMine, -} from 'lbry-redux'; +import { makeSelectFileInfoForUri, makeSelectDownloadingForUri, makeSelectClaimIsMine } from 'lbry-redux'; import { doOpenModal } from 'redux/actions/app'; import { doSetPlayingUri, doPlayUri } from 'redux/actions/content'; import FileDownloadLink from './view'; @@ -12,7 +7,6 @@ import FileDownloadLink from './view'; const select = (state, props) => ({ fileInfo: makeSelectFileInfoForUri(props.uri)(state), downloading: makeSelectDownloadingForUri(props.uri)(state), - loading: makeSelectLoadingForUri(props.uri)(state), claimIsMine: makeSelectClaimIsMine(props.uri)(state), }); diff --git a/src/ui/component/fileDownloadLink/view.jsx b/src/ui/component/fileDownloadLink/view.jsx index 226d92a36..997fea0a5 100644 --- a/src/ui/component/fileDownloadLink/view.jsx +++ b/src/ui/component/fileDownloadLink/view.jsx @@ -9,7 +9,6 @@ type Props = { uri: string, claimIsMine: boolean, downloading: boolean, - loading: boolean, isStreamable: boolean, fileInfo: ?FileListItem, openModal: (id: string, { path: string }) => void, @@ -18,9 +17,9 @@ type Props = { }; function FileDownloadLink(props: Props) { - const { fileInfo, downloading, loading, openModal, pause, claimIsMine, download, uri } = props; + const { fileInfo, downloading, openModal, pause, claimIsMine, download, uri } = props; - if (downloading || loading) { + if (downloading) { const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; const label = fileInfo && fileInfo.written_bytes > 0 ? progress.toFixed(0) + __('% downloaded') : __('Connecting...'); diff --git a/src/ui/modal/modalRemoveFile/view.jsx b/src/ui/modal/modalRemoveFile/view.jsx index fd5d1192a..dcf3817bc 100644 --- a/src/ui/modal/modalRemoveFile/view.jsx +++ b/src/ui/modal/modalRemoveFile/view.jsx @@ -48,7 +48,7 @@ function ModalRemoveFile(props: Props) { /> )}
-
diff --git a/src/ui/redux/actions/file.js b/src/ui/redux/actions/file.js index 82f139f2f..5800191f9 100644 --- a/src/ui/redux/actions/file.js +++ b/src/ui/redux/actions/file.js @@ -53,7 +53,7 @@ export function doDeleteFileAndMaybeGoBack(uri, deleteFromComputer, abandonClaim return (dispatch, getState) => { const state = getState(); const playingUri = selectPlayingUri(state); - const { outpoint } = makeSelectFileInfoForUri(uri)(state); + const { outpoint } = makeSelectFileInfoForUri(uri)(state) || ''; const actions = []; actions.push(doHideModal()); actions.push(doDeleteFile(outpoint, deleteFromComputer, abandonClaim)); diff --git a/yarn.lock b/yarn.lock index 2c15167d4..601f02249 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6762,9 +6762,9 @@ lazy-val@^1.0.3, lazy-val@^1.0.4: yargs "^13.2.2" zstd-codec "^0.1.1" -lbry-redux@lbryio/lbry-redux#027c517ec653f328eeed2cf509b1062b0f787f22: +lbry-redux@lbryio/lbry-redux#1af092ce2cb507d9a41711b864874c0bd76935ae: version "0.0.1" - resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/027c517ec653f328eeed2cf509b1062b0f787f22" + resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/1af092ce2cb507d9a41711b864874c0bd76935ae" dependencies: mime "^2.4.4" proxy-polyfill "0.1.6" From f99869a3dc93f1318c425c86feb172654b6982d7 Mon Sep 17 00:00:00 2001 From: Sean Yesmunt Date: Thu, 15 Aug 2019 10:26:20 -0400 Subject: [PATCH 2/2] auto claim download rewards on file watch --- src/ui/component/fileDownloadLink/index.js | 8 +++++++- src/ui/component/fileDownloadLink/view.jsx | 5 +++-- src/ui/component/fileViewer/index.js | 2 ++ src/ui/component/fileViewer/view.jsx | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/ui/component/fileDownloadLink/index.js b/src/ui/component/fileDownloadLink/index.js index 88fcffcec..2481ef9e8 100644 --- a/src/ui/component/fileDownloadLink/index.js +++ b/src/ui/component/fileDownloadLink/index.js @@ -1,5 +1,10 @@ import { connect } from 'react-redux'; -import { makeSelectFileInfoForUri, makeSelectDownloadingForUri, makeSelectClaimIsMine } from 'lbry-redux'; +import { + makeSelectFileInfoForUri, + makeSelectDownloadingForUri, + makeSelectLoadingForUri, + makeSelectClaimIsMine, +} from 'lbry-redux'; import { doOpenModal } from 'redux/actions/app'; import { doSetPlayingUri, doPlayUri } from 'redux/actions/content'; import FileDownloadLink from './view'; @@ -7,6 +12,7 @@ import FileDownloadLink from './view'; const select = (state, props) => ({ fileInfo: makeSelectFileInfoForUri(props.uri)(state), downloading: makeSelectDownloadingForUri(props.uri)(state), + loading: makeSelectLoadingForUri(props.uri)(state), claimIsMine: makeSelectClaimIsMine(props.uri)(state), }); diff --git a/src/ui/component/fileDownloadLink/view.jsx b/src/ui/component/fileDownloadLink/view.jsx index 997fea0a5..226d92a36 100644 --- a/src/ui/component/fileDownloadLink/view.jsx +++ b/src/ui/component/fileDownloadLink/view.jsx @@ -9,6 +9,7 @@ type Props = { uri: string, claimIsMine: boolean, downloading: boolean, + loading: boolean, isStreamable: boolean, fileInfo: ?FileListItem, openModal: (id: string, { path: string }) => void, @@ -17,9 +18,9 @@ type Props = { }; function FileDownloadLink(props: Props) { - const { fileInfo, downloading, openModal, pause, claimIsMine, download, uri } = props; + const { fileInfo, downloading, loading, openModal, pause, claimIsMine, download, uri } = props; - if (downloading) { + if (downloading || loading) { const progress = fileInfo && fileInfo.written_bytes > 0 ? (fileInfo.written_bytes / fileInfo.total_bytes) * 100 : 0; const label = fileInfo && fileInfo.written_bytes > 0 ? progress.toFixed(0) + __('% downloaded') : __('Connecting...'); diff --git a/src/ui/component/fileViewer/index.js b/src/ui/component/fileViewer/index.js index 5551fec66..3dce437cc 100644 --- a/src/ui/component/fileViewer/index.js +++ b/src/ui/component/fileViewer/index.js @@ -8,6 +8,7 @@ import { makeSelectUriIsStreamable, makeSelectTitleForUri, } from 'lbry-redux'; +import { doClaimEligiblePurchaseRewards } from 'lbryinc'; import { makeSelectIsPlaying, makeSelectShouldObscurePreview, selectPlayingUri } from 'redux/selectors/content'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import { doSetPlayingUri } from 'redux/actions/content'; @@ -34,6 +35,7 @@ const select = (state, props) => { const perform = dispatch => ({ clearPlayingUri: () => dispatch(doSetPlayingUri(null)), triggerAnalyticsView: (uri, timeToStart) => dispatch(doAnalyticsView(uri, timeToStart)), + claimRewards: () => dispatch(doClaimEligiblePurchaseRewards()), }); export default withRouter( diff --git a/src/ui/component/fileViewer/view.jsx b/src/ui/component/fileViewer/view.jsx index 8797e2baf..e7efd4979 100644 --- a/src/ui/component/fileViewer/view.jsx +++ b/src/ui/component/fileViewer/view.jsx @@ -29,6 +29,7 @@ type Props = { floatingPlayerEnabled: boolean, clearPlayingUri: () => void, triggerAnalyticsView: (string, number) => void, + claimRewards: () => void, }; export default function FileViewer(props: Props) { @@ -43,6 +44,7 @@ export default function FileViewer(props: Props) { clearPlayingUri, floatingPlayerEnabled, triggerAnalyticsView, + claimRewards, } = props; const [playTime, setPlayTime] = useState(); const [fileViewerRect, setFileViewerRect] = usePersistedState('inline-file-viewer:rect'); @@ -73,9 +75,10 @@ export default function FileViewer(props: Props) { if (playTime && isReadyToPlay && wasntReadyButNowItIs) { const timeToStart = Date.now() - playTime; triggerAnalyticsView(uri, timeToStart); + claimRewards(); setPlayTime(null); } - }, [setPlayTime, triggerAnalyticsView, isReadyToPlay, wasntReadyButNowItIs, playTime, uri]); + }, [setPlayTime, triggerAnalyticsView, isReadyToPlay, wasntReadyButNowItIs, playTime, uri, claimRewards]); useEffect(() => { function handleResize() {