From 330997bc1eedf232812ffe9a1f5ca48d0197dd3a Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Thu, 22 Aug 2019 15:51:57 +0100 Subject: [PATCH 1/4] edit published content --- package-lock.json | 6 +- package.json | 2 +- src/component/channelSelector/view.js | 9 +- src/component/uriBar/view.js | 15 ++++ src/index.js | 1 + src/page/file/index.js | 8 +- src/page/file/view.js | 39 +++++--- src/page/publish/view.js | 125 ++++++++++++++++++++------ src/page/publishes/view.js | 15 +++- src/styles/filePage.js | 4 + src/styles/uriBar.js | 3 + 11 files changed, 182 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index a20eca7..c10b865 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8046,9 +8046,9 @@ } }, "react-native-document-picker": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/react-native-document-picker/-/react-native-document-picker-2.3.0.tgz", - "integrity": "sha512-bHMyAOzFl+II0ZdfzobKsZKvTErmXfmQGalpxpGbeN8+/uhfhUcdp4WuIMecZhFyX6rbj3h3XXLdA12hVlGgmw==" + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/react-native-document-picker/-/react-native-document-picker-3.2.4.tgz", + "integrity": "sha512-5l0/fkgasUZdIk9jUUkReDtNCQn2yg1+BrMPHMt45c/NVmE15ThnhIuDj8/n8h1F1RlhUb3SzF86ANK4OdZAiQ==" }, "react-native-exception-handler": { "version": "2.9.0", diff --git a/package.json b/package.json index 8a0beb9..b8120a3 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "@react-native-community/async-storage": "^1.5.1", "react-native-camera": "^2.11.1", "react-native-country-picker-modal": "^0.6.2", - "react-native-document-picker": "^2.3.0", + "react-native-document-picker": "^3.2.4", "react-native-exception-handler": "2.9.0", "react-native-fast-image": "^6.1.1", "react-native-fs": "^2.13.3", diff --git a/src/component/channelSelector/view.js b/src/component/channelSelector/view.js index f81c363..96b02a5 100644 --- a/src/component/channelSelector/view.js +++ b/src/component/channelSelector/view.js @@ -26,12 +26,19 @@ export default class ChannelSelector extends React.PureComponent { } componentDidMount() { - const { channels, fetchChannelListMine, fetchingChannels } = this.props; + const { channels, channelName, fetchChannelListMine, fetchingChannels } = this.props; if (!channels.length && !fetchingChannels) { fetchChannelListMine(); } } + componentDidUpdate() { + const { channelName } = this.props; + if (this.state.currentSelectedValue !== channelName) { + this.setState({ currentSelectedValue: channelName }); + } + } + handleCreateCancel = () => { this.setState({ showCreateChannel: false, newChannelName: '', newChannelBid: 0.1 }); }; diff --git a/src/component/uriBar/view.js b/src/component/uriBar/view.js index d2350e3..1097ec7 100644 --- a/src/component/uriBar/view.js +++ b/src/component/uriBar/view.js @@ -135,9 +135,11 @@ class UriBar extends React.PureComponent { render() { const { + allowEdit, belowOverlay, navigation, onExitSelectionMode, + onEditActionPressed, onDeleteActionPressed, query, selectedItemCount, @@ -175,6 +177,19 @@ class UriBar extends React.PureComponent { + {allowEdit && selectedItemCount === 1 && ( + { + if (onEditActionPressed) { + onEditActionPressed(); + } + }} + > + + + )} + { diff --git a/src/index.js b/src/index.js index b6e0b91..6cd831d 100644 --- a/src/index.js +++ b/src/index.js @@ -43,6 +43,7 @@ import thunk from 'redux-thunk'; const globalExceptionHandler = (error, isFatal) => { if (error && NativeModules.Firebase) { + console.log(error); NativeModules.Firebase.logException(isFatal, error.message ? error.message : 'No message', JSON.stringify(error)); } }; diff --git a/src/page/file/index.js b/src/page/file/index.js index 78a2e5d..79c5e97 100644 --- a/src/page/file/index.js +++ b/src/page/file/index.js @@ -1,6 +1,7 @@ import { connect } from 'react-redux'; import { doFetchFileInfo, + doFetchClaimListMine, doFileGet, doPurchaseUri, doDeletePurchasedUri, @@ -18,6 +19,7 @@ import { makeSelectThumbnailForUri, makeSelectTitleForUri, selectBalance, + selectMyClaimUrisWithoutChannels, selectPurchasedUris, selectFailedPurchaseUris, selectPurchaseUriErrorMessage, @@ -50,14 +52,15 @@ const select = (state, props) => { contentType: makeSelectContentTypeForUri(selectProps.uri)(state), costInfo: makeSelectCostInfoForUri(selectProps.uri)(state), metadata: makeSelectMetadataForUri(selectProps.uri)(state), - //obscureNsfw: !selectShowNsfw(state), - //tab: makeSelectCurrentParam('tab')(state), + // obscureNsfw: !selectShowNsfw(state), + // tab: makeSelectCurrentParam('tab')(state), fileInfo: makeSelectFileInfoForUri(selectProps.uri)(state), rewardedContentClaimIds: selectRewardContentClaimIds(state, selectProps), channelUri: makeSelectChannelForClaimUri(selectProps.uri, true)(state), position: makeSelectContentPositionForUri(selectProps.uri)(state), purchasedUris: selectPurchasedUris(state), failedPurchaseUris: selectFailedPurchaseUris(state), + myClaimUris: selectMyClaimUrisWithoutChannels(state), purchaseUriErrorMessage: selectPurchaseUriErrorMessage(state), streamingUrl: makeSelectStreamingUrlForUri(selectProps.uri)(state), thumbnail: makeSelectThumbnailForUri(selectProps.uri)(state), @@ -71,6 +74,7 @@ const perform = dispatch => ({ }, fetchFileInfo: uri => dispatch(doFetchFileInfo(uri)), fetchCostInfo: uri => dispatch(doFetchCostInfoForUri(uri)), + fetchMyClaims: () => dispatch(doFetchClaimListMine()), fileGet: (uri, saveFile) => dispatch(doFileGet(uri, saveFile)), notify: data => dispatch(doToast(data)), popDrawerStack: () => dispatch(doPopDrawerStack()), diff --git a/src/page/file/view.js b/src/page/file/view.js index 18e2316..6f6b1ed 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -231,6 +231,11 @@ class FilePage extends React.PureComponent { } }; + onEditPressed = () => { + const { claim, navigation } = this.props; + navigation.navigate({ routeName: Constants.DRAWER_ROUTE_PUBLISH, params: { editMode: true, claimToEdit: claim } }); + }; + onDeletePressed = () => { const { claim, deleteFile, deletePurchasedUri, fileInfo, navigation } = this.props; @@ -243,11 +248,11 @@ class FilePage extends React.PureComponent { text: 'Yes', onPress: () => { const { uri } = navigation.state.params; + deleteFile(`${claim.txid}:${claim.nout}`, true); deletePurchasedUri(uri); - if (NativeModules.UtilityModule) { - NativeModules.UtilityModule.deleteDownload(uri); - } + + NativeModules.UtilityModule.deleteDownload(uri); this.setState({ downloadPressed: false, fileViewLogged: false, @@ -568,6 +573,7 @@ class FilePage extends React.PureComponent { rewardedContentClaimIds, isResolvingUri, blackListedOutpoints, + myClaimUris, navigation, position, purchaseUri, @@ -640,19 +646,20 @@ class FilePage extends React.PureComponent { const isPlayable = mediaType === 'video' || mediaType === 'audio'; const { height, signing_channel: signingChannel, value } = claim; const channelName = signingChannel && signingChannel.name; + const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id; + const canSendTip = this.state.tipAmount > 0; + const fullUri = `${claim.name}#${claim.claim_id}`; + const canEdit = myClaimUris.includes(normalizeURI(fullUri)); const showActions = - fileInfo && - fileInfo.download_path && + (canEdit || (fileInfo && fileInfo.download_path)) && !this.state.fullscreenMode && !this.state.showImageViewer && !this.state.showWebView; const showFileActions = - fileInfo && - fileInfo.download_path && - (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes)); - const channelClaimId = claim && claim.signing_channel && claim.signing_channel.claim_id; - const canSendTip = this.state.tipAmount > 0; - const fullUri = `${claim.name}#${claim.claim_id}`; + canEdit || + (fileInfo && + fileInfo.download_path && + (completed || (fileInfo && !fileInfo.stopped && fileInfo.written_bytes < fileInfo.total_bytes))); const fullChannelUri = channelClaimId && channelClaimId.trim().length > 0 ? normalizeURI(`${channelName}#${channelClaimId}`) @@ -823,6 +830,16 @@ class FilePage extends React.PureComponent { {showFileActions && ( + {canEdit && ( +