error on publish to existing content address

This commit is contained in:
Akinwale Ariwodola 2020-01-20 21:52:59 +01:00
parent 46bfbd242a
commit 3717a8072b
3 changed files with 21 additions and 8 deletions

View file

@ -1,6 +1,7 @@
import { connect } from 'react-redux';
import {
doPublish,
doFetchClaimListMine,
doResolveUri,
doToast,
doUpdatePublishForm,
@ -27,6 +28,7 @@ const select = state => ({
const perform = dispatch => ({
notify: data => dispatch(doToast(data)),
clearPublishFormState: () => dispatch(doClearPublishFormState()),
fetchMyClaims: () => dispatch(doFetchClaimListMine()),
pendingPublishSuccess: pendingClaim => dispatch(doPendingPublishSuccess(pendingClaim)),
updatePublishForm: value => dispatch(doUpdatePublishForm(value)),
updatePublishFormState: data => dispatch(doUpdatePublishFormState(data)),
@ -39,5 +41,5 @@ const perform = dispatch => ({
export default connect(
select,
perform
perform,
)(PublishPage);

View file

@ -209,7 +209,7 @@ class PublishPage extends React.PureComponent {
};
onComponentFocused = () => {
const { balance, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
const { balance, fetchMyClaims, hasFormState, pushDrawerStack, setPlayerVisible, navigation } = this.props;
NativeModules.Firebase.setCurrentScreen('Publish').then(result => {
pushDrawerStack(Constants.DRAWER_ROUTE_PUBLISH, navigation.state.params ? navigation.state.params : null);
setPlayerVisible();
@ -219,6 +219,7 @@ class PublishPage extends React.PureComponent {
NativeModules.Gallery.canUseCamera().then(canUseCamera => this.setState({ canUseCamera }));
NativeModules.Gallery.getThumbnailPath().then(thumbnailPath => this.setState({ thumbnailPath }));
fetchMyClaims();
NativeModules.UtilityModule.canReadWriteStorage().then(canReadWrite => {
if (!canReadWrite) {
@ -356,7 +357,7 @@ class PublishPage extends React.PureComponent {
};
handlePublishPressed = () => {
const { balance, notify, publish, updatePublishForm } = this.props;
const { balance, myClaims, notify, publish, updatePublishForm } = this.props;
const {
editMode,
bid,
@ -400,6 +401,14 @@ class PublishPage extends React.PureComponent {
if (!isNameValid(name, false)) {
notify({ message: __('Your content address contains invalid characters.'), isError: true });
return;
} else if (myClaims && myClaims.length > 0) {
if (myClaims.some(claim => claim.name.toLowerCase() === name.trim().toLowerCase())) {
notify({
message: __('You have already published to the specified content address. Please enter a new address.'),
isError: true,
});
return;
}
}
if (!currentMedia && !editMode) {
@ -628,7 +637,7 @@ class PublishPage extends React.PureComponent {
}
} else {
// could not determine the file path
notify({ message: __('The path could not be determined. Please try a different file.') });
notify({ message: __('The path could not be determined. Please try a different file.'), isError: true });
}
};

View file

@ -59,10 +59,12 @@ class SplashScreen extends React.PureComponent {
} else if (lastRouteInStack) {
// no launch url, check if there's a last route in stack to navigate to.
const { route, params } = lastRouteInStack;
if (!DrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route);
} else {
navigation.navigate({ routeName: route, params });
if (route) {
if (!DrawerRoutes.includes(route) && isURIValid(route)) {
navigateToUri(navigation, route);
} else {
navigation.navigate({ routeName: route, params });
}
}
}
};