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 ab89e00..4acd2ee 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..4584ce9 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 }); }; @@ -171,7 +178,7 @@ export default class ChannelSelector extends React.PureComponent { render() { const channel = this.state.addingChannel ? 'new' : this.props.channel; - const { fetchingChannels, channels = [] } = this.props; + const { enabled, fetchingChannels, channels = [] } = this.props; const pickerItems = [Constants.ITEM_ANONYMOUS, Constants.ITEM_CREATE_A_CHANNEL].concat(channels.map(ch => ch.name)); const { @@ -188,6 +195,7 @@ export default class ChannelSelector extends React.PureComponent { return ( + {allowEdit && selectedItemCount === 1 && ( + { + if (onEditActionPressed) { + onEditActionPressed(); + } + }} + > + + + )} + { 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 99fee98..8ff225d 100644 --- a/src/page/file/view.js +++ b/src/page/file/view.js @@ -232,6 +232,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; @@ -244,11 +249,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, @@ -571,6 +576,7 @@ class FilePage extends React.PureComponent { rewardedContentClaimIds, isResolvingUri, blackListedOutpoints, + myClaimUris, navigation, position, purchaseUri, @@ -643,19 +649,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}`) @@ -826,6 +833,16 @@ class FilePage extends React.PureComponent { {showFileActions && ( + {canEdit && ( +